merge OS/2 style PATH (absolute with drive letters, ‘;’ as separator)
From: KO Myung-Hun <komh@chollian.net>
This commit is contained in:
13
check.pl
13
check.pl
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.pl,v 1.39 2015/04/29 19:01:03 tg Exp $
|
# $MirOS: src/bin/mksh/check.pl,v 1.40 2015/07/10 19:36:31 tg Exp $
|
||||||
# $OpenBSD: th,v 1.1 2013/12/02 20:39:44 millert Exp $
|
# $OpenBSD: th,v 1.1 2013/12/02 20:39:44 millert Exp $
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011,
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011,
|
||||||
@ -73,11 +73,12 @@
|
|||||||
# the following minimal environment:
|
# the following minimal environment:
|
||||||
# HOME, LD_LIBRARY_PATH, LOCPATH,
|
# HOME, LD_LIBRARY_PATH, LOCPATH,
|
||||||
# LOGNAME, PATH, SHELL, UNIXMODE,
|
# LOGNAME, PATH, SHELL, UNIXMODE,
|
||||||
# USER
|
# UNIXROOT, USER
|
||||||
# (values taken from the environment of
|
# (values taken from the environment of
|
||||||
# the test harness).
|
# the test harness).
|
||||||
# CYGWIN is set to nodosfilewarning.
|
# CYGWIN is set to nodosfilewarning.
|
||||||
# ENV is set to /nonexistant.
|
# ENV is set to /nonexistant.
|
||||||
|
# PATHSEP is set to either : or ;.
|
||||||
# __progname is set to the -p argument.
|
# __progname is set to the -p argument.
|
||||||
# __perlname is set to $^X (perlexe).
|
# __perlname is set to $^X (perlexe).
|
||||||
# file-setup mps Used to create files, directories
|
# file-setup mps Used to create files, directories
|
||||||
@ -275,11 +276,12 @@ $all_tests = @ARGV == 0;
|
|||||||
# Set up a very minimal environment
|
# Set up a very minimal environment
|
||||||
%new_env = ();
|
%new_env = ();
|
||||||
foreach $env (('HOME', 'LD_LIBRARY_PATH', 'LOCPATH', 'LOGNAME',
|
foreach $env (('HOME', 'LD_LIBRARY_PATH', 'LOCPATH', 'LOGNAME',
|
||||||
'PATH', 'SHELL', 'UNIXMODE', 'USER')) {
|
'PATH', 'SHELL', 'UNIXMODE', 'UNIXROOT', 'USER')) {
|
||||||
$new_env{$env} = $ENV{$env} if defined $ENV{$env};
|
$new_env{$env} = $ENV{$env} if defined $ENV{$env};
|
||||||
}
|
}
|
||||||
$new_env{'CYGWIN'} = 'nodosfilewarning';
|
$new_env{'CYGWIN'} = 'nodosfilewarning';
|
||||||
$new_env{'ENV'} = '/nonexistant';
|
$new_env{'ENV'} = '/nonexistant';
|
||||||
|
$new_env{'PATHSEP'} = $os eq 'os2' ? ';' : ':';
|
||||||
if (($os eq 'VMS') || ($Config{perlpath} =~ m/$Config{_exe}$/i)) {
|
if (($os eq 'VMS') || ($Config{perlpath} =~ m/$Config{_exe}$/i)) {
|
||||||
$new_env{'__perlname'} = $Config{perlpath};
|
$new_env{'__perlname'} = $Config{perlpath};
|
||||||
} else {
|
} else {
|
||||||
@ -312,9 +314,10 @@ die "$prog: couldn't get temporary directory\n" if $temp_dir eq '';
|
|||||||
die "$prog: couldn't cd to $pwd - $!\n" if !chdir($pwd);
|
die "$prog: couldn't cd to $pwd - $!\n" if !chdir($pwd);
|
||||||
|
|
||||||
if (!$program_kludge) {
|
if (!$program_kludge) {
|
||||||
$test_prog = "$pwd/$test_prog" if substr($test_prog, 0, 1) ne '/';
|
$test_prog = "$pwd/$test_prog" if (substr($test_prog, 0, 1) ne '/') &&
|
||||||
|
($os ne 'os2' || substr($test_prog, 1, 1) ne ':');
|
||||||
die "$prog: $test_prog is not executable - bye\n"
|
die "$prog: $test_prog is not executable - bye\n"
|
||||||
if (! -x $test_prog && $os ne 'os2');
|
if (! -x $test_prog && $os ne 'os2');
|
||||||
}
|
}
|
||||||
|
|
||||||
@trap_sigs = ('TERM', 'QUIT', 'INT', 'PIPE', 'HUP');
|
@trap_sigs = ('TERM', 'QUIT', 'INT', 'PIPE', 'HUP');
|
||||||
|
99
check.t
99
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.702 2015/07/09 20:52:36 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.703 2015/07/10 19:36:31 tg Exp $
|
||||||
# -*- mode: sh -*-
|
# -*- mode: sh -*-
|
||||||
#-
|
#-
|
||||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
@ -30,7 +30,7 @@
|
|||||||
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
|
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R51 2015/07/09
|
@(#)MIRBSD KSH R51 2015/07/10
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -39,7 +39,7 @@ name: KSH_VERSION
|
|||||||
category: shell:legacy-no
|
category: shell:legacy-no
|
||||||
---
|
---
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)LEGACY KSH R51 2015/07/09
|
@(#)LEGACY KSH R51 2015/07/10
|
||||||
description:
|
description:
|
||||||
Check version of legacy shell.
|
Check version of legacy shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -232,7 +232,7 @@ time-limit: 3
|
|||||||
stdin:
|
stdin:
|
||||||
print '#!'"$__progname"'\necho tf' >lq
|
print '#!'"$__progname"'\necho tf' >lq
|
||||||
chmod +x lq
|
chmod +x lq
|
||||||
PATH=$PWD:$PATH
|
PATH=$PWD$PATHSEP$PATH
|
||||||
alias lq=lq
|
alias lq=lq
|
||||||
lq
|
lq
|
||||||
echo = now
|
echo = now
|
||||||
@ -5557,7 +5557,7 @@ description:
|
|||||||
stdin:
|
stdin:
|
||||||
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
|
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
|
||||||
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
|
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
|
||||||
done >env; chmod +x env; PATH=.:$PATH
|
done >env; chmod +x env; PATH=.$PATHSEP$PATH
|
||||||
foo=bar
|
foo=bar
|
||||||
readonly foo
|
readonly foo
|
||||||
foo=stuff env | grep '^foo'
|
foo=stuff env | grep '^foo'
|
||||||
@ -6263,7 +6263,7 @@ description:
|
|||||||
stdin:
|
stdin:
|
||||||
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
|
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
|
||||||
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
|
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
|
||||||
done >env; chmod +x env; PATH=.:$PATH
|
done >env; chmod +x env; PATH=.$PATHSEP$PATH
|
||||||
FOO=bar exec env
|
FOO=bar exec env
|
||||||
expected-stdout-pattern:
|
expected-stdout-pattern:
|
||||||
/(^|.*\n)FOO=bar\n/
|
/(^|.*\n)FOO=bar\n/
|
||||||
@ -6275,7 +6275,7 @@ description:
|
|||||||
stdin:
|
stdin:
|
||||||
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
|
print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
|
||||||
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
|
'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
|
||||||
done >env; chmod +x env; PATH=.:$PATH
|
done >env; chmod +x env; PATH=.$PATHSEP$PATH
|
||||||
env >bar1
|
env >bar1
|
||||||
FOO=bar exec; env >bar2
|
FOO=bar exec; env >bar2
|
||||||
cmp -s bar1 bar2
|
cmp -s bar1 bar2
|
||||||
@ -6519,7 +6519,7 @@ stdin:
|
|||||||
print '#!'"$__progname"'\nexec "$1"' >env
|
print '#!'"$__progname"'\nexec "$1"' >env
|
||||||
print '#!'"$__progname"'\nexit 1' >false
|
print '#!'"$__progname"'\nexit 1' >false
|
||||||
chmod +x env false
|
chmod +x env false
|
||||||
PATH=.:$PATH
|
PATH=.$PATHSEP$PATH
|
||||||
set -ex
|
set -ex
|
||||||
env false && echo something
|
env false && echo something
|
||||||
echo END
|
echo END
|
||||||
@ -6537,7 +6537,7 @@ stdin:
|
|||||||
print '#!'"$__progname"'\nexit 1' >false
|
print '#!'"$__progname"'\nexit 1' >false
|
||||||
print '#!'"$__progname"'\nexit 0' >true
|
print '#!'"$__progname"'\nexit 0' >true
|
||||||
chmod +x env false
|
chmod +x env false
|
||||||
PATH=.:$PATH
|
PATH=.$PATHSEP$PATH
|
||||||
set -ex
|
set -ex
|
||||||
if env true; then
|
if env true; then
|
||||||
env false && echo something
|
env false && echo something
|
||||||
@ -7281,7 +7281,7 @@ stdin:
|
|||||||
set -A anzahl -- foo/*
|
set -A anzahl -- foo/*
|
||||||
echo got ${#anzahl[*]} files
|
echo got ${#anzahl[*]} files
|
||||||
chmod +x foo/*
|
chmod +x foo/*
|
||||||
export PATH=$(pwd)/foo:$PATH
|
export PATH=$(pwd)/foo$PATHSEP$PATH
|
||||||
"$__progname" -c 'fnord'
|
"$__progname" -c 'fnord'
|
||||||
echo =
|
echo =
|
||||||
"$__progname" -c 'fnord; fnord; fnord; fnord'
|
"$__progname" -c 'fnord; fnord; fnord; fnord'
|
||||||
@ -7451,7 +7451,7 @@ expected-stdout:
|
|||||||
name: aliases-1
|
name: aliases-1
|
||||||
description:
|
description:
|
||||||
Check if built-in shell aliases are okay
|
Check if built-in shell aliases are okay
|
||||||
category: !android,!arge
|
category: !android,!arge,!os:os2
|
||||||
stdin:
|
stdin:
|
||||||
alias
|
alias
|
||||||
typeset -f
|
typeset -f
|
||||||
@ -7491,10 +7491,31 @@ expected-stdout:
|
|||||||
source='PATH=$PATH:. \command .'
|
source='PATH=$PATH:. \command .'
|
||||||
type='\builtin whence -v'
|
type='\builtin whence -v'
|
||||||
---
|
---
|
||||||
|
name: aliases-1-os2
|
||||||
|
description:
|
||||||
|
Check if built-in shell aliases are okay
|
||||||
|
category: os:os2
|
||||||
|
stdin:
|
||||||
|
alias
|
||||||
|
typeset -f
|
||||||
|
expected-stdout:
|
||||||
|
autoload='\typeset -fu'
|
||||||
|
functions='\typeset -f'
|
||||||
|
hash='\builtin alias -t'
|
||||||
|
history='\builtin fc -l'
|
||||||
|
integer='\typeset -i'
|
||||||
|
local='\typeset'
|
||||||
|
login='\exec login'
|
||||||
|
nameref='\typeset -n'
|
||||||
|
nohup='nohup '
|
||||||
|
r='\builtin fc -e -'
|
||||||
|
source='PATH=$PATH;. \command .'
|
||||||
|
type='\builtin whence -v'
|
||||||
|
---
|
||||||
name: aliases-2b
|
name: aliases-2b
|
||||||
description:
|
description:
|
||||||
Check if “set -o sh” does not influence built-in aliases
|
Check if “set -o sh” does not influence built-in aliases
|
||||||
category: !android,!arge
|
category: !android,!arge,!os:os2
|
||||||
arguments: !-o!sh!
|
arguments: !-o!sh!
|
||||||
stdin:
|
stdin:
|
||||||
alias
|
alias
|
||||||
@ -7517,7 +7538,7 @@ expected-stdout:
|
|||||||
name: aliases-3b
|
name: aliases-3b
|
||||||
description:
|
description:
|
||||||
Check if running as sh does not influence built-in aliases
|
Check if running as sh does not influence built-in aliases
|
||||||
category: !android,!arge
|
category: !android,!arge,!os:os2
|
||||||
stdin:
|
stdin:
|
||||||
cp "$__progname" sh
|
cp "$__progname" sh
|
||||||
./sh -c 'alias; typeset -f'
|
./sh -c 'alias; typeset -f'
|
||||||
@ -7581,6 +7602,50 @@ expected-stdout:
|
|||||||
source='PATH=$PATH:. \command .'
|
source='PATH=$PATH:. \command .'
|
||||||
type='\builtin whence -v'
|
type='\builtin whence -v'
|
||||||
---
|
---
|
||||||
|
name: aliases-2b-os2
|
||||||
|
description:
|
||||||
|
Check if “set -o sh” does not influence built-in aliases
|
||||||
|
category: os:os2
|
||||||
|
arguments: !-o!sh!
|
||||||
|
stdin:
|
||||||
|
alias
|
||||||
|
typeset -f
|
||||||
|
expected-stdout:
|
||||||
|
autoload='\typeset -fu'
|
||||||
|
functions='\typeset -f'
|
||||||
|
hash='\builtin alias -t'
|
||||||
|
history='\builtin fc -l'
|
||||||
|
integer='\typeset -i'
|
||||||
|
local='\typeset'
|
||||||
|
login='\exec login'
|
||||||
|
nameref='\typeset -n'
|
||||||
|
nohup='nohup '
|
||||||
|
r='\builtin fc -e -'
|
||||||
|
source='PATH=$PATH;. \command .'
|
||||||
|
type='\builtin whence -v'
|
||||||
|
---
|
||||||
|
name: aliases-3b-os2
|
||||||
|
description:
|
||||||
|
Check if running as sh does not influence built-in aliases
|
||||||
|
category: os:os2
|
||||||
|
stdin:
|
||||||
|
cp "$__progname" sh
|
||||||
|
./sh -c 'alias; typeset -f'
|
||||||
|
rm -f sh
|
||||||
|
expected-stdout:
|
||||||
|
autoload='\typeset -fu'
|
||||||
|
functions='\typeset -f'
|
||||||
|
hash='\builtin alias -t'
|
||||||
|
history='\builtin fc -l'
|
||||||
|
integer='\typeset -i'
|
||||||
|
local='\typeset'
|
||||||
|
login='\exec login'
|
||||||
|
nameref='\typeset -n'
|
||||||
|
nohup='nohup '
|
||||||
|
r='\builtin fc -e -'
|
||||||
|
source='PATH=$PATH;. \command .'
|
||||||
|
type='\builtin whence -v'
|
||||||
|
---
|
||||||
name: aliases-cmdline
|
name: aliases-cmdline
|
||||||
description:
|
description:
|
||||||
Check that aliases work from the command line (Debian #517009)
|
Check that aliases work from the command line (Debian #517009)
|
||||||
@ -9907,7 +9972,7 @@ description:
|
|||||||
FOO=bar f
|
FOO=bar f
|
||||||
where f is a ksh style function, should not set FOO in the current
|
where f is a ksh style function, should not set FOO in the current
|
||||||
env. If f is a Bourne style function, FOO should be set. Furthermore,
|
env. If f is a Bourne style function, FOO should be set. Furthermore,
|
||||||
the function should receive a correct value of FOO. However, differing
|
the function should receive a correct value of FOO. However, differing
|
||||||
from oksh, setting FOO in the function itself must change the value in
|
from oksh, setting FOO in the function itself must change the value in
|
||||||
setting FOO in the function itself should not change the value in
|
setting FOO in the function itself should not change the value in
|
||||||
global environment.
|
global environment.
|
||||||
@ -10079,7 +10144,7 @@ description:
|
|||||||
echo $x
|
echo $x
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
yes
|
yes
|
||||||
---
|
---
|
||||||
name: comsub-3
|
name: comsub-3
|
||||||
description:
|
description:
|
||||||
Extended test for COMSUB explaining why a recursive parser
|
Extended test for COMSUB explaining why a recursive parser
|
||||||
@ -11314,7 +11379,7 @@ file-setup: file 755 "!false"
|
|||||||
description:
|
description:
|
||||||
Check that '!' substitution in noninteractive mode is ignored
|
Check that '!' substitution in noninteractive mode is ignored
|
||||||
file-setup: file 755 "falsetto"
|
file-setup: file 755 "falsetto"
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
echo molto bene
|
echo molto bene
|
||||||
exit 42
|
exit 42
|
||||||
file-setup: file 755 "!false"
|
file-setup: file 755 "!false"
|
||||||
@ -11344,7 +11409,7 @@ file-setup: file 755 "!false"
|
|||||||
need-ctty: yes
|
need-ctty: yes
|
||||||
arguments: !-i!
|
arguments: !-i!
|
||||||
file-setup: file 755 "falsetto"
|
file-setup: file 755 "falsetto"
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
echo molto bene
|
echo molto bene
|
||||||
exit 42
|
exit 42
|
||||||
file-setup: file 755 "!false"
|
file-setup: file 755 "!false"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.99 2015/07/05 19:02:16 tg Exp $
|
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.100 2015/07/10 19:36:33 tg Exp $
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
|
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
|
||||||
# 2011, 2012, 2013, 2014, 2015
|
# 2011, 2012, 2013, 2014, 2015
|
||||||
@ -406,6 +406,7 @@ function enable {
|
|||||||
i_alias[nalias]=nameref; b_alias[nalias++]='\typeset -n'
|
i_alias[nalias]=nameref; b_alias[nalias++]='\typeset -n'
|
||||||
i_alias[nalias]=nohup; b_alias[nalias++]='nohup '
|
i_alias[nalias]=nohup; b_alias[nalias++]='nohup '
|
||||||
i_alias[nalias]=r; b_alias[nalias++]='\builtin fc -e -'
|
i_alias[nalias]=r; b_alias[nalias++]='\builtin fc -e -'
|
||||||
|
#XXX OS/2
|
||||||
i_alias[nalias]=source; b_alias[nalias++]='PATH=$PATH:. \command .'
|
i_alias[nalias]=source; b_alias[nalias++]='PATH=$PATH:. \command .'
|
||||||
i_alias[nalias]=stop; b_alias[nalias++]='\kill -STOP'
|
i_alias[nalias]=stop; b_alias[nalias++]='\kill -STOP'
|
||||||
i_alias[nalias]=type; b_alias[nalias++]='\builtin whence -v'
|
i_alias[nalias]=type; b_alias[nalias++]='\builtin whence -v'
|
||||||
@ -582,6 +583,7 @@ function enable {
|
|||||||
|
|
||||||
for p in ~/.etc/bin ~/bin; do
|
for p in ~/.etc/bin ~/bin; do
|
||||||
[[ -d $p/. ]] || \continue
|
[[ -d $p/. ]] || \continue
|
||||||
|
#XXX OS/2
|
||||||
[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
|
[[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
|
||||||
done
|
done
|
||||||
|
|
||||||
|
4
edit.c
4
edit.c
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.289 2015/07/10 18:41:05 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.290 2015/07/10 19:36:34 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in later versions we might use libtermcap for this, but since external
|
* in later versions we might use libtermcap for this, but since external
|
||||||
@ -771,7 +771,7 @@ glob_path(int flags, const char *pat, XPtrV *wp, const char *lpath)
|
|||||||
Xinit(xs, xp, patlen + 128, ATEMP);
|
Xinit(xs, xp, patlen + 128, ATEMP);
|
||||||
while (sp) {
|
while (sp) {
|
||||||
xp = Xstring(xs, xp);
|
xp = Xstring(xs, xp);
|
||||||
if (!(p = cstrchr(sp, ':')))
|
if (!(p = cstrchr(sp, MKSH_PATHSEPC)))
|
||||||
p = sp + strlen(sp);
|
p = sp + strlen(sp);
|
||||||
pathlen = p - sp;
|
pathlen = p - sp;
|
||||||
if (pathlen) {
|
if (pathlen) {
|
||||||
|
8
exec.c
8
exec.c
@ -23,10 +23,10 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.159 2015/07/09 20:52:38 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.160 2015/07/10 19:36:35 tg Exp $");
|
||||||
|
|
||||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||||
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int comexec(struct op *, struct tbl * volatile, const char **,
|
static int comexec(struct op *, struct tbl * volatile, const char **,
|
||||||
@ -1247,7 +1247,7 @@ flushcom(bool all)
|
|||||||
struct tstate ts;
|
struct tstate ts;
|
||||||
|
|
||||||
for (ktwalk(&ts, &taliases); (tp = ktnext(&ts)) != NULL; )
|
for (ktwalk(&ts, &taliases); (tp = ktnext(&ts)) != NULL; )
|
||||||
if ((tp->flag&ISSET) && (all || tp->val.s[0] != '/')) {
|
if ((tp->flag&ISSET) && (all || !mksh_abspath(tp->val.s))) {
|
||||||
if (tp->flag&ALLOC) {
|
if (tp->flag&ALLOC) {
|
||||||
tp->flag &= ~(ALLOC|ISSET);
|
tp->flag &= ~(ALLOC|ISSET);
|
||||||
afree(tp->val.s, APERM);
|
afree(tp->val.s, APERM);
|
||||||
@ -1308,7 +1308,7 @@ search_path(const char *name, const char *lpath,
|
|||||||
sp = lpath;
|
sp = lpath;
|
||||||
while (sp != NULL) {
|
while (sp != NULL) {
|
||||||
xp = Xstring(xs, xp);
|
xp = Xstring(xs, xp);
|
||||||
if (!(p = cstrchr(sp, ':')))
|
if (!(p = cstrchr(sp, MKSH_PATHSEPC)))
|
||||||
p = sp + strlen(sp);
|
p = sp + strlen(sp);
|
||||||
if (p != sp) {
|
if (p != sp) {
|
||||||
XcheckN(xs, xp, p - sp);
|
XcheckN(xs, xp, p - sp);
|
||||||
|
15
main.c
15
main.c
@ -34,7 +34,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.299 2015/07/09 20:52:40 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.300 2015/07/10 19:36:35 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ extern char **environ;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MKSH_DEFAULT_TMPDIR
|
#ifndef MKSH_DEFAULT_TMPDIR
|
||||||
#define MKSH_DEFAULT_TMPDIR "/tmp"
|
#define MKSH_DEFAULT_TMPDIR MKSH_UNIXROOT "/tmp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t isuc(const char *);
|
static uint8_t isuc(const char *);
|
||||||
@ -82,7 +82,7 @@ static const char *initcoms[] = {
|
|||||||
"nameref=\\typeset -n",
|
"nameref=\\typeset -n",
|
||||||
"nohup=nohup ",
|
"nohup=nohup ",
|
||||||
"r=\\builtin fc -e -",
|
"r=\\builtin fc -e -",
|
||||||
"source=PATH=$PATH:. \\command .",
|
"source=PATH=$PATH" MKSH_PATHSEPS ". \\command .",
|
||||||
"login=\\exec login",
|
"login=\\exec login",
|
||||||
NULL,
|
NULL,
|
||||||
/* this is what AT&T ksh seems to track, with the addition of emacs */
|
/* this is what AT&T ksh seems to track, with the addition of emacs */
|
||||||
@ -324,7 +324,10 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
|
|||||||
* "keeping a regular /usr"; this is supposed
|
* "keeping a regular /usr"; this is supposed
|
||||||
* to be a sane 'basic' default PATH
|
* to be a sane 'basic' default PATH
|
||||||
*/
|
*/
|
||||||
def_path = "/bin:/usr/bin:/sbin:/usr/sbin";
|
def_path = MKSH_UNIXROOT "/bin" MKSH_PATHSEPS
|
||||||
|
MKSH_UNIXROOT "/usr/bin" MKSH_PATHSEPS
|
||||||
|
MKSH_UNIXROOT "/sbin" MKSH_PATHSEPS
|
||||||
|
MKSH_UNIXROOT "/usr/sbin";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -367,7 +370,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
|
|||||||
vp = global("PWD");
|
vp = global("PWD");
|
||||||
cp = str_val(vp);
|
cp = str_val(vp);
|
||||||
/* Try to use existing $PWD if it is valid */
|
/* Try to use existing $PWD if it is valid */
|
||||||
set_current_wd((cp[0] == '/' && test_eval(NULL, TO_FILEQ, cp, ".",
|
set_current_wd((mksh_abspath(cp) && test_eval(NULL, TO_FILEQ, cp, ".",
|
||||||
true)) ? cp : NULL);
|
true)) ? cp : NULL);
|
||||||
if (current_wd[0])
|
if (current_wd[0])
|
||||||
simplify_path(current_wd);
|
simplify_path(current_wd);
|
||||||
@ -1372,7 +1375,7 @@ initio(void)
|
|||||||
shf_fdopen(2, SHF_WR, shl_xtrace);
|
shf_fdopen(2, SHF_WR, shl_xtrace);
|
||||||
#ifdef DF
|
#ifdef DF
|
||||||
if ((lfp = getenv("SDMKSH_PATH")) == NULL) {
|
if ((lfp = getenv("SDMKSH_PATH")) == NULL) {
|
||||||
if ((lfp = getenv("HOME")) == NULL || *lfp != '/')
|
if ((lfp = getenv("HOME")) == NULL || !mksh_abspath(lfp))
|
||||||
errorf("cannot get home directory");
|
errorf("cannot get home directory");
|
||||||
lfp = shf_smprintf("%s/mksh-dbg.txt", lfp);
|
lfp = shf_smprintf("%s/mksh-dbg.txt", lfp);
|
||||||
}
|
}
|
||||||
|
22
misc.c
22
misc.c
@ -30,7 +30,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.237 2015/07/09 20:52:41 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.238 2015/07/10 19:36:36 tg Exp $");
|
||||||
|
|
||||||
#define KSH_CHVT_FLAG
|
#define KSH_CHVT_FLAG
|
||||||
#ifdef MKSH_SMALL
|
#ifdef MKSH_SMALL
|
||||||
@ -1412,12 +1412,12 @@ do_realpath(const char *upath)
|
|||||||
/* max. recursion depth */
|
/* max. recursion depth */
|
||||||
int symlinks = 32;
|
int symlinks = 32;
|
||||||
|
|
||||||
if (upath[0] == '/') {
|
if (mksh_abspath(upath)) {
|
||||||
/* upath is an absolute pathname */
|
/* upath is an absolute pathname */
|
||||||
strdupx(ipath, upath, ATEMP);
|
strdupx(ipath, upath, ATEMP);
|
||||||
} else {
|
} else {
|
||||||
/* upath is a relative pathname, prepend cwd */
|
/* upath is a relative pathname, prepend cwd */
|
||||||
if ((tp = ksh_get_wd()) == NULL || tp[0] != '/')
|
if ((tp = ksh_get_wd()) == NULL || !mksh_abspath(tp))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
ipath = shf_smprintf("%s%s%s", tp, "/", upath);
|
ipath = shf_smprintf("%s%s%s", tp, "/", upath);
|
||||||
afree(tp, ATEMP);
|
afree(tp, ATEMP);
|
||||||
@ -1520,7 +1520,7 @@ do_realpath(const char *upath)
|
|||||||
tp = shf_smprintf("%s%s%s", ldest, *ip ? "/" : "", ip);
|
tp = shf_smprintf("%s%s%s", ldest, *ip ? "/" : "", ip);
|
||||||
afree(ipath, ATEMP);
|
afree(ipath, ATEMP);
|
||||||
ip = ipath = tp;
|
ip = ipath = tp;
|
||||||
if (ldest[0] != '/') {
|
if (!mksh_abspath(ldest)) {
|
||||||
/* symlink target is a relative path */
|
/* symlink target is a relative path */
|
||||||
xp = Xrestpos(xs, xp, pos);
|
xp = Xrestpos(xs, xp, pos);
|
||||||
} else
|
} else
|
||||||
@ -1620,7 +1620,7 @@ make_path(const char *cwd, const char *file,
|
|||||||
if (!file)
|
if (!file)
|
||||||
file = null;
|
file = null;
|
||||||
|
|
||||||
if (file[0] == '/') {
|
if (mksh_abspath(file)) {
|
||||||
*phys_pathp = 0;
|
*phys_pathp = 0;
|
||||||
use_cdpath = false;
|
use_cdpath = false;
|
||||||
} else {
|
} else {
|
||||||
@ -1637,15 +1637,15 @@ make_path(const char *cwd, const char *file,
|
|||||||
if (!plist)
|
if (!plist)
|
||||||
use_cdpath = false;
|
use_cdpath = false;
|
||||||
else if (use_cdpath) {
|
else if (use_cdpath) {
|
||||||
char *pend;
|
char *pend = plist;
|
||||||
|
|
||||||
for (pend = plist; *pend && *pend != ':'; pend++)
|
while (*pend && *pend != MKSH_PATHSEPC)
|
||||||
;
|
++pend;
|
||||||
plen = pend - plist;
|
plen = pend - plist;
|
||||||
*cdpathp = *pend ? pend + 1 : NULL;
|
*cdpathp = *pend ? pend + 1 : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!use_cdpath || !plen || plist[0] != '/') &&
|
if ((!use_cdpath || !plen || !mksh_abspath(plist)) &&
|
||||||
(cwd && *cwd)) {
|
(cwd && *cwd)) {
|
||||||
len = strlen(cwd);
|
len = strlen(cwd);
|
||||||
XcheckN(*xsp, xp, len);
|
XcheckN(*xsp, xp, len);
|
||||||
@ -1731,7 +1731,7 @@ simplify_path(char *p)
|
|||||||
continue;
|
continue;
|
||||||
else if (len == 2 && tp[1] == '.') {
|
else if (len == 2 && tp[1] == '.') {
|
||||||
/* parent level, but how? */
|
/* parent level, but how? */
|
||||||
if (*p == '/')
|
if (mksh_abspath(p))
|
||||||
/* absolute path, only one way */
|
/* absolute path, only one way */
|
||||||
goto strip_last_component;
|
goto strip_last_component;
|
||||||
else if (dp > sp) {
|
else if (dp > sp) {
|
||||||
@ -1931,7 +1931,7 @@ c_cd(const char **wp)
|
|||||||
/* Ignore failure (happens if readonly or integer) */
|
/* Ignore failure (happens if readonly or integer) */
|
||||||
setstr(oldpwd_s, current_wd, KSH_RETURN_ERROR);
|
setstr(oldpwd_s, current_wd, KSH_RETURN_ERROR);
|
||||||
|
|
||||||
if (Xstring(xs, xp)[0] != '/') {
|
if (!mksh_abspath(Xstring(xs, xp))) {
|
||||||
pwd = NULL;
|
pwd = NULL;
|
||||||
} else if (!physical) {
|
} else if (!physical) {
|
||||||
goto norealpath_PWD;
|
goto norealpath_PWD;
|
||||||
|
24
sh.h
24
sh.h
@ -172,9 +172,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.738 2015/07/09 20:52:42 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.739 2015/07/10 19:36:37 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R51 2015/07/09"
|
#define MKSH_VERSION "R51 2015/07/10"
|
||||||
|
|
||||||
/* arithmetic types: C implementation */
|
/* arithmetic types: C implementation */
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
@ -381,9 +381,19 @@ struct rusage {
|
|||||||
|
|
||||||
#ifdef MKSH_EXE_EXT
|
#ifdef MKSH_EXE_EXT
|
||||||
#undef MKSH_EXE_EXT
|
#undef MKSH_EXE_EXT
|
||||||
#define MKSH_EXE_EXT ".exe"
|
#define MKSH_EXE_EXT ".exe"
|
||||||
#else
|
#else
|
||||||
#define MKSH_EXE_EXT ""
|
#define MKSH_EXE_EXT ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __OS2__
|
||||||
|
#define MKSH_PATHSEPS ";"
|
||||||
|
#define MKSH_PATHSEPC ';'
|
||||||
|
#define MKSH_UNIXROOT "/@unixroot"
|
||||||
|
#else
|
||||||
|
#define MKSH_PATHSEPS ":"
|
||||||
|
#define MKSH_PATHSEPC ':'
|
||||||
|
#define MKSH_UNIXROOT ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAVE_FLOCK_DECL
|
#if !HAVE_FLOCK_DECL
|
||||||
@ -2100,9 +2110,15 @@ extern int tty_init_fd(void); /* initialise tty_fd, tty_devtty */
|
|||||||
setmode(binopen3_fd, O_BINARY); \
|
setmode(binopen3_fd, O_BINARY); \
|
||||||
(binopen3_fd); \
|
(binopen3_fd); \
|
||||||
})
|
})
|
||||||
|
#define mksh_abspath(s) __extension__({ \
|
||||||
|
const char *mksh_abspath_s = (s); \
|
||||||
|
(mksh_abspath_s[0] == '/' || (ksh_isalphx(mksh_abspath_s[0]) && \
|
||||||
|
mksh_abspath_s[1] == ':')); \
|
||||||
|
})
|
||||||
#else
|
#else
|
||||||
#define binopen2(path,flags) open((path), (flags) | O_BINARY)
|
#define binopen2(path,flags) open((path), (flags) | O_BINARY)
|
||||||
#define binopen3(path,flags,mode) open((path), (flags) | O_BINARY, (mode))
|
#define binopen3(path,flags,mode) open((path), (flags) | O_BINARY, (mode))
|
||||||
|
#define mksh_abspath(s) ((s)[0] == '/')
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* be sure not to interfere with anyone else's idea about EXTERN */
|
/* be sure not to interfere with anyone else's idea about EXTERN */
|
||||||
|
4
var.c
4
var.c
@ -28,7 +28,7 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.192 2015/04/29 20:07:35 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.193 2015/07/10 19:36:38 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Variables
|
* Variables
|
||||||
@ -1281,7 +1281,7 @@ setspec(struct tbl *vp)
|
|||||||
|
|
||||||
s = str_val(vp);
|
s = str_val(vp);
|
||||||
/* LINTED use of access */
|
/* LINTED use of access */
|
||||||
if (s[0] == '/' && access(s, W_OK|X_OK) == 0 &&
|
if (mksh_abspath(s) && access(s, W_OK|X_OK) == 0 &&
|
||||||
stat(s, &statb) == 0 && S_ISDIR(statb.st_mode))
|
stat(s, &statb) == 0 && S_ISDIR(statb.st_mode))
|
||||||
strdupx(tmpdir, s, APERM);
|
strdupx(tmpdir, s, APERM);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user