ksh/ksh93.dif

566 lines
15 KiB
Plaintext
Raw Normal View History

--- src/cmd/ksh93/bltins/print.c
+++ src/cmd/ksh93/bltins/print.c 2008-05-05 11:20:21.000000000 +0000
@@ -86,7 +86,11 @@ static char* nullarg[] = { 0, 0 };
{
static char bsd_univ;
struct print prdata;
- prdata.options = sh_optecho+5;
+# if defined(__linux__)
+ prdata.options = sh_optecho;
+# else
+ prdata.options = sh_optecho + 5;
+# endif
prdata.raw = prdata.echon = 0;
prdata.sh = context->shp;
NOT_USED(argc);
@@ -99,7 +103,52 @@ static char* nullarg[] = { 0, 0 };
prdata.sh->universe = 1;
}
if(!bsd_univ)
+ {
+# if defined(__linux__)
+ char *opt = argv[1];
+ while ((opt = argv[1]) && (*opt == '-'))
+ {
+ int c;
+
+ opt++;
+
+ for (c = 0; opt[c]; c++)
+# if !SHOPT_ECHOE
+ if (strchr("neE", opt[c]) == 0)
+# else
+ if (strchr("n", opt[c]) == 0)
+# endif /* SHOPT_ECHOE */
+ break;
+
+ if (*opt == 0 || opt[c])
+ break;
+
+ while ((c = *opt++))
+ {
+ switch (c) {
+ case 'n':
+ prdata.echon = 1;
+ break;
+# if !SHOPT_ECHOE
+ case 'e':
+ prdata.raw = 0;
+ break;
+ case 'E':
+ prdata.raw = 1;
+ break;
+# endif /* SHOPT_ECHOE */
+ default:
+ goto out;
+ break;
+ }
+ }
+
+ argv++;
+ }
+ out:
+# endif
return(b_print(0,argv,(Shbltin_t*)&prdata));
+ }
prdata.options = sh_optecho;
prdata.raw = 1;
while(argv[1] && *argv[1]=='-')
--- src/cmd/ksh93/data/msg.c
+++ src/cmd/ksh93/data/msg.c 2007-12-20 18:01:26.000000000 +0000
@@ -199,7 +199,7 @@ const char e_bash_login[] = "$HOME/.bash
const char e_bash_logout[] = "$HOME/.bash_logout";
const char e_bash_profile[] = "$HOME/.bash_profile";
#endif
-const char e_crondir[] = "/usr/spool/cron/atjobs";
+const char e_crondir[] = "/var/spool/cron";
const char e_prohibited[] = "login setuid/setgid shells prohibited";
#if SHOPT_SUID_EXEC
const char e_suidexec[] = "/etc/suid_exec";
--- src/cmd/ksh93/data/variables.c
+++ src/cmd/ksh93/data/variables.c 2008-09-18 17:22:24.000000000 +0000
@@ -68,7 +68,7 @@ const struct shtable2 shtab_variables[]
"OPTARG", 0, (char*)0,
"OPTIND", NV_NOFREE|NV_INTEGER, (char*)0,
"PS4", 0, (char*)0,
- "FPATH", 0, (char*)0,
+ "FPATH", NV_NOFREE, "/usr/share/ksh/fun",
"LANG", 0, (char*)0,
"LC_ALL", 0, (char*)0,
"LC_COLLATE", 0, (char*)0,
--- src/cmd/ksh93/features/options
+++ src/cmd/ksh93/features/options 2007-12-20 18:01:26.000000000 +0000
@@ -36,7 +36,7 @@ tst cross{
option TEST_L $?
test -f /etc/ksh.kshrc -o -f /etc/bash.bashrc &&
option SYSRC 0
- test -f /bin/universe && univ=`/bin/universe` > /dev/null 2>&1 -a ucb = "$univ"
+ test -x /bin/universe && univ=`/bin/universe` > /dev/null 2>&1 && test ucb = "$univ"
option UCB $?
}end
--- src/cmd/ksh93/sh.1
+++ src/cmd/ksh93/sh.1 2008-09-22 12:11:56.000000000 +0000
@@ -200,7 +200,7 @@ separated by
.BR \(bv .
The standard output of each command but the last
is connected by a
-.IR pipe (2)
+.IR socketpair (2)
to the standard input of the next command.
Each command,
except possibly the last,
--- src/cmd/ksh93/sh/lex.c
+++ src/cmd/ksh93/sh/lex.c 2010-08-17 14:49:14.000000000 +0000
@@ -1136,7 +1136,11 @@ int sh_lex(Lex_t* lp)
if(!(state=lp->lexd.first))
state = fcfirst();
else
- fcseek(state-fcseek(0));
+ {
+ register const char * cp;
+ cp = fcseek(0);
+ fcseek(state-cp);
+ }
lp->lexd.paren = 1;
}
return(lp->token=LPAREN);
--- src/cmd/ksh93/sh/main.c
+++ src/cmd/ksh93/sh/main.c 2007-12-20 18:01:26.000000000 +0000
@@ -130,9 +130,9 @@ int sh_source(Shell_t *shp, Sfio_t *iop,
}
#ifdef S_ISSOCK
-#define REMOTE(m) (S_ISSOCK(m)||!(m))
+#define REMOTE(m) ((S_ISSOCK((m).st_mode)||!((m).st_mode))&&!((m).st_ino))
#else
-#define REMOTE(m) !(m)
+#define REMOTE(m) (!((m).st_mode)&&!((m).st_ino))
#endif
int sh_main(int ac, char *av[], Shinit_f userinit)
@@ -199,7 +199,7 @@ int sh_main(int ac, char *av[], Shinit_f
}
if(!sh_isoption(SH_RC) && (sh_isoption(SH_BASH) && !sh_isoption(SH_POSIX)
#if SHOPT_REMOTE
- || !fstat(0, &statb) && REMOTE(statb.st_mode)
+ || !fstat(0, &statb) && REMOTE(statb)
#endif
))
sh_onoption(SH_RC);
--- src/cmd/ksh93/sh/xec.c
+++ src/cmd/ksh93/sh/xec.c 2012-01-26 12:07:46.463645375 +0000
@@ -922,7 +922,7 @@ int sh_exec(register const Shnode_t *t,
{
case TCOM:
{
- register struct argnod *argp;
+ volatile struct argnod *argp;
char *trap;
Namval_t *np, *nq, *last_table;
struct ionod *io;
@@ -1027,7 +1027,7 @@ int sh_exec(register const Shnode_t *t,
comn = com[argn-1];
}
io = t->tre.treio;
- if(shp->envlist = argp = t->com.comset)
+ if((shp->envlist = argp = t->com.comset))
{
if(argn==0 || (np && nv_isattr(np,(BLT_DCL|BLT_SPC))))
{
--- src/cmd/ksh93/tests/attributes.sh
+++ src/cmd/ksh93/tests/attributes.sh 2009-07-09 13:14:05.000000000 +0000
@@ -199,7 +199,7 @@ hello worldhello worldhello world
[[ $v1 == "$b1" ]] || err_exit "v1=$v1 should be $b1"
[[ $v2 == "$x" ]] || err_exit "v1=$v2 should be $x"
if env '!=1' >/dev/null 2>&1
-then [[ $(env '!=1' $SHELL -c 'echo ok' 2>/dev/null) == ok ]] || err_exit 'malformed environment terminates shell'
+then [[ $(env "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" '!=1' $SHELL -c 'echo ok' 2>/dev/null) == ok ]] || err_exit 'malformed environment terminates shell'
fi
unset var
typeset -b var
--- src/cmd/ksh93/tests/bracket.sh
+++ src/cmd/ksh93/tests/bracket.sh 2012-02-09 14:11:32.365933854 +0000
@@ -221,6 +221,10 @@ done
[[ abcdcdabcde == {5}(ab|cd)e ]] || err_exit 'abcdcdabcd == {5}(ab|cd)e'
) || err_exit 'errors with {..}(...) patterns'
[[ D290.2003.02.16.temp == D290.+(2003.02.16).temp* ]] || err_exit 'pattern match bug with +(...)'
+atime=$(stat -c '%X' $file)
+sleep 2
+cat $file > /dev/null
+if [[ $atime -lt $(stat -c '%X' $file) ]] then
rm -rf $file
{
[[ -N $file ]] && err_exit 'test -N $tmp/*: st_mtime>st_atime after creat'
@@ -231,6 +235,7 @@ sleep 2
read
[[ -N $file ]] && err_exit 'test -N $tmp/*: st_mtime>st_atime after read'
} > $file < $file
+fi
if rm -rf "$file" && ln -s / "$file"
then [[ -L "$file" ]] || err_exit '-L not working'
[[ -L "$file"/ ]] && err_exit '-L with file/ not working'
--- src/cmd/ksh93/tests/builtins.sh
+++ src/cmd/ksh93/tests/builtins.sh 2009-07-09 13:14:50.000000000 +0000
@@ -332,7 +332,7 @@ wait $pid1
(( $? == 1 )) || err_exit "wait not saving exit value"
wait $pid2
(( $? == 127 )) || err_exit "subshell job known to parent"
-env=
+env="LD_LIBRARY_PATH=\$LD_LIBRARY_PATH"
v=$(getconf LIBPATH)
for v in ${v//,/ }
do v=${v#*:}
--- src/cmd/ksh93/tests/coprocess.sh
+++ src/cmd/ksh93/tests/coprocess.sh 2012-02-09 13:39:13.794169756 +0000
@@ -107,15 +107,15 @@ ${SHELL-ksh} |&
cop=$!
exp=Done
print -p $'print hello | cat\nprint '$exp
-read -t 5 -p
-read -t 5 -p
+read -t 50 -p
+read -t 50 -p
got=$REPLY
if [[ $got != $exp ]]
then err_exit "${SHELL-ksh} coprocess io failed -- got '$got', expected '$exp'"
fi
exec 5<&p 6>&p
exec 5<&- 6>&-
-{ sleep 4; kill $cop; } 2>/dev/null &
+{ sleep 10; kill $cop; } 2>/dev/null &
spy=$!
if wait $cop 2>/dev/null
then kill $spy 2>/dev/null
@@ -128,10 +128,10 @@ echo line1 | grep 'line2'
echo line2 | grep 'line1'
} |&
SECONDS=0 count=0
-while read -p -t 10 line
+while read -p -t 100 line
do ((count++))
done
-if (( SECONDS > 8 ))
+if (( SECONDS > 80 ))
then err_exit "read -p hanging (SECONDS=$SECONDS count=$count)"
fi
wait $!
@@ -154,7 +154,7 @@ e=12345
wait $!
done
print
-) 2>/dev/null | read -t 10 r
+) 2>/dev/null | read -t 100 r
[[ $r == $e ]] || err_exit "coprocess timing bug -- expected $e, got '$r'"
r=
(
@@ -166,8 +166,9 @@ r=
wait $!
done
print $r
-) 2>/dev/null | read -t 10 r
+) 2>/dev/null | read -t 100 r
[[ $r == $e ]] || err_exit "coprocess command substitution bug -- expected $e, got '$r'"
+kill $(jobs -p) 2>/dev/null
(
/bin/cat |&
@@ -205,7 +206,7 @@ do if ( trap - $sig ) 2> /dev/null
done
trap 'sleep_pid=; kill $pid; err_exit "coprocess 1 hung"' TERM
-{ sleep 5; kill $$; } &
+{ sleep 10; kill $$; } &
sleep_pid=$!
builtin cat
cat |&
@@ -220,7 +221,7 @@ trap - TERM
[[ $sleep_pid ]] && kill $sleep_pid
trap 'sleep_pid=; kill $pid; err_exit "coprocess 2 hung"' TERM
-{ sleep 5; kill $$; } &
+{ sleep 10; kill $$; } &
sleep_pid=$!
cat |&
pid=$!
@@ -232,7 +233,7 @@ trap - TERM
[[ $sleep_pid ]] && kill $sleep_pid
trap 'sleep_pid=; kill $pid; err_exit "coprocess 3 hung"' TERM
-{ sleep 5; kill $$; } &
+{ sleep 10; kill $$; } &
sleep_pid=$!
cat |&
pid=$!
--- src/cmd/ksh93/tests/locale.sh
+++ src/cmd/ksh93/tests/locale.sh 2011-05-24 16:46:02.000000000 +0200
@@ -62,7 +62,7 @@ done
# this locale is supported by ast on all platforms
# EU for { decimal_point="," thousands_sep="." }
-locale=C_EU.UTF-8
+locale=de_DE.UTF-8
export LC_ALL=C
@@ -111,11 +111,11 @@ set -- $($SHELL -c "
unset LC_CTYPE
export LANG=$locale
export LC_ALL=C
- command wc -C < $tmp/two_euro_chars.txt
+ command wc -m < $tmp/two_euro_chars.txt
unset LC_ALL
- command wc -C < $tmp/two_euro_chars.txt
+ command wc -m < $tmp/two_euro_chars.txt
export LC_ALL=C
- command wc -C < $tmp/two_euro_chars.txt
+ command wc -m < $tmp/two_euro_chars.txt
")
got=$*
[[ $got == $exp ]] || err_exit "command wc LC_ALL default failed -- expected '$exp', got '$got'"
@@ -124,11 +124,11 @@ set -- $($SHELL -c "
then unset LC_CTYPE
export LANG=$locale
export LC_ALL=C
- wc -C < $tmp/two_euro_chars.txt
+ wc -m < $tmp/two_euro_chars.txt
unset LC_ALL
- wc -C < $tmp/two_euro_chars.txt
+ wc -m < $tmp/two_euro_chars.txt
export LC_ALL=C
- wc -C < $tmp/two_euro_chars.txt
+ wc -m < $tmp/two_euro_chars.txt
fi
")
got=$*
--- src/cmd/ksh93/tests/options.sh
+++ src/cmd/ksh93/tests/options.sh 2012-01-16 16:50:59.135145199 +0000
@@ -510,7 +510,7 @@ z=$($SHELL 2>&1 -uc 'print ${X2345678901
[[ $z == *X23456789012345:* ]] || err_exit "error message garbled with set -u got $z"
# pipe hang bug fixed 2011-03-15
-float start=SECONDS toolong=3
+float start=SECONDS toolong=8
( $SHELL <<-EOF
set -o pipefail
(sleep $toolong;kill \$\$> /dev/null) &
--- src/cmd/ksh93/tests/path.sh
+++ src/cmd/ksh93/tests/path.sh 2008-09-11 16:02:46.000000000 +0000
@@ -269,7 +269,7 @@ builtin getconf
getconf UNIVERSE - att # override sticky default 'UNIVERSE = foo'
[[ $(PATH=/usr/ucb/bin:/usr/bin echo -n ucb) == 'ucb' ]] || err_exit "ucb universe echo ignores -n option"
-[[ $(PATH=/usr/xpg/bin:/usr/bin echo -n att) == '-n att' ]] || err_exit "att universe echo does not ignore -n option"
+[[ $(PATH=/usr/xpg/bin:/usr/bin echo -n att) == 'att' ]] || err_exit "att universe echo ignores -n option"
PATH=$path
--- src/cmd/ksh93/tests/pty.sh
+++ src/cmd/ksh93/tests/pty.sh 2012-02-20 13:49:24.729935773 +0000
@@ -419,16 +419,16 @@ r echo repeat-3
!
# err_exit #
-whence -q less &&
+whence -q more &&
TERM=vt100 tst $LINENO <<"!"
L ksh process/terminal group exercise
-w while :; do echo y; done | less
-u ^:\E
+w while :; do echo y; done | more
+u --More--
c \cZ
r Stopped
w fg
-u ^:\E
+w q
!
exit $((Errors<125?Errors:125))
--- src/cmd/ksh93/tests/signal.sh
+++ src/cmd/ksh93/tests/signal.sh 2011-05-20 13:25:48.196426330 +0000
@@ -285,10 +285,10 @@ then for exp in TERM VTALRM PIPE
$SHELL <<- EOF
foo() { return 0; }
trap foo EXIT
- { sleep 2; kill -$exp \$\$; sleep 3; kill -0 \$\$ && kill -KILL \$\$; } &
+ { sleep 2; kill -$exp \$\$; sleep 8; kill -0 \$\$ && kill -KILL \$\$; } &
$yes |
while read yes
- do (/bin/date; sleep .1)
+ do (/bin/date; sleep .01)
done > /dev/null
EOF
} 2>> /dev/null
--- src/lib/libast/disc/memfatal.c
+++ src/lib/libast/disc/memfatal.c 2009-07-09 13:30:39.000000000 +0000
@@ -72,7 +72,7 @@ memfatal(void)
{
Vmdisc_t* disc;
- malloc(0);
+ void * ptr = malloc(0);
if (disc = vmdisc(Vmregion, NiL))
disc->exceptf = nomalloc;
}
--- src/lib/libast/features/align.c
+++ src/lib/libast/features/align.c 2007-12-20 18:01:26.000000000 +0000
@@ -32,6 +32,7 @@
#include "FEATURE/common"
#include <setjmp.h>
+#include <stdio.h>
union _u_
{
--- src/lib/libast/features/botch.c
+++ src/lib/libast/features/botch.c 2007-12-20 18:01:26.000000000 +0000
@@ -27,6 +27,7 @@
* generate ast traps for botched standard prototypes
*/
+#include <stdio.h>
#include <sys/types.h>
#include "FEATURE/lib"
--- src/lib/libast/features/lib
+++ src/lib/libast/features/lib 2007-12-20 18:01:26.000000000 +0000
@@ -523,14 +523,19 @@ tst lib_utime_now note{ utime works with
}end
tst cross{
- u=att
- case `/bin/cat -s /dev/null/foo 2>&1` in
- '') ;;
- *) case `/bin/echo '\\t'` in
- '\t') u=ucb ;;
+ if test -n "$UNIVERSE"
+ then
+ u=$UNIVERSE
+ else
+ u=att
+ case `/bin/cat -s /dev/null/foo 2>&1` in
+ '') ;;
+ *) case `/bin/echo '\\t'` in
+ '\t') u=ucb ;;
+ esac
+ ;;
esac
- ;;
- esac
+ fi
echo "#define _UNIV_DEFAULT \"$u\" /* default universe name */"
}end
--- src/lib/libast/misc/procopen.c
+++ src/lib/libast/misc/procopen.c 2007-12-20 18:01:26.000000000 +0000
@@ -598,7 +598,7 @@ procopen(const char* cmd, char** argv, c
if (!fork())
{
sfsprintf(path, sizeof(path), "%d", getppid());
- execlp("trace", "trace", "-p", path, NiL);
+ execlp("trace", "trace", "-p", path, NULL);
_exit(EXIT_NOTFOUND);
}
sleep(2);
--- src/lib/libast/port/astwinsize.c
+++ src/lib/libast/port/astwinsize.c 2012-02-03 08:58:43.217934605 +0000
@@ -29,6 +29,10 @@
#include <ast.h>
#include <ast_tty.h>
+#if _sys_ioctl
+#include <sys/ioctl.h>
+#endif
+
#if defined(__STDPP__directive) && defined(__STDPP__hide)
__STDPP__directive pragma pp:hide ioctl sleep
#else
@@ -36,10 +40,6 @@ __STDPP__directive pragma pp:hide ioctl
#define sleep ______sleep
#endif
-#if _sys_ioctl
-#include <sys/ioctl.h>
-#endif
-
#if defined(TIOCGWINSZ)
#if _sys_stream && _sys_ptem
#include <sys/stream.h>
--- src/lib/libast/sfio/sfstrtof.h
+++ src/lib/libast/sfio/sfstrtof.h 2007-12-20 18:01:26.000000000 +0000
@@ -54,7 +54,7 @@
#if !defined(S2F_function)
#define S2F_function _sfdscan
-#define S2F_static 1
+#define S2F_static -1
#define S2F_type 2
#define S2F_scan 1
#ifndef elementsof
--- src/lib/libcmd/chmod.c
+++ src/lib/libcmd/chmod.c 2011-05-20 13:28:57.511927049 +0000
@@ -272,7 +272,7 @@ b_chmod(int argc, char** argv, void* con
case FTS_SLNONE:
if (chlink)
{
-#if _lib_lchmod
+#if !defined(__linux__) && _lib_lchmod
chmodf = lchmod;
goto commit;
#else
--- src/lib/libcmd/vmstate.c
+++ src/lib/libcmd/vmstate.c 2012-02-21 13:10:56.085934573 +0000
@@ -50,6 +50,7 @@ USAGE_LICENSE
#include <cmd.h>
#include <vmalloc.h>
+#include <sfdisc.h>
typedef struct State_s
{
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c 2012-02-20 10:33:24.362018545 +0000
@@ -508,25 +508,26 @@ static void put_cdpath(register Namval_t
static void put_ifs(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
{
register struct ifs *ip = (struct ifs*)fp;
+ Namfun_t *xp;
ip->ifsnp = 0;
- if(!val)
+ if(val)
{
- fp = nv_stack(np, NIL(Namfun_t*));
- if(fp && !fp->nofree)
- {
- free((void*)fp);
- fp = 0;
- }
+ if(val != np->nvalue.cp)
+ nv_putv(np, val, flags, fp);
+ return;
}
- if(val != np->nvalue.cp)
- nv_putv(np, val, flags, fp);
- if(!val)
+ if((xp = nv_stack(np, NIL(Namfun_t*))) != fp)
+ sfprintf(sfstderr, "BUG in %s:%s(%d) xp(%p) != fp(%p)\n",
+ __FILE__, __FUNCTION__, __LINE__, xp, fp);
+ if(fp && !fp->nofree)
{
- fp->next = np->nvfun;
- np->nvfun = fp;
+ free((void*)fp);
+ fp = NIL(Namfun_t*);
}
- else if(!val)
- np->nvfun = 0;
+ nv_putv(np, NIL(char*), flags, fp);
+ if(fp)
+ fp->next = np->nvfun;
+ np->nvfun = fp;
}
/*