Date: 2009/12/05 NOTE: This patch is only necessary on OpenSolaris and has no effect on other systems. Apply by doing: % cd osh-20091127 % patch -p0 < osh-20091127-p1.patch Then, rebuild and reinstall per instructions in INSTALL file. You may do `% osh GotoTest' to test for expected goto behavior. No output and zero exit status indicates that GotoTest passed. -- Jeffrey Allen Neitzel =================================================================== --- ../osh-20091127.orig/CHANGES 2009-11-27 18:46:14.000000000 +0000 +++ ./CHANGES 2009-12-05 04:34:07.000000000 +0000 @@ -2,6 +2,16 @@ Thompson shell are marked w/ a `C:' in the details below. ------------------------------------------------------------------------------- +[osh-20091127-p1]: +mkconfig: + * Define CONFIG_SUNOS on OpenSolaris (uname -s == SunOS). + +goto.c: + * Fixed problem w/ external goto command on OpenSolaris where file + offset set via lseek(2) isn't shared w/ parent process, causing + unexpected behavior. + +------------------------------------------------------------------------------- [osh-20091127]: err.c: * Changed setmyname(argv[0]) so that it only ditches an initial --- ../osh-20091127.orig/Makefile 2009-11-27 18:46:14.000000000 +0000 +++ ./Makefile 2009-12-05 04:34:50.000000000 +0000 @@ -63,9 +63,10 @@ # osh-YYYYMMDD-current == development snapshot # osh-YYYYMMDD-beta.* == beta release # osh-YYYYMMDD == official release +# osh-YYYYMMDD-p[1-9] == patched release # OSH_DATE= November 27, 2009 -OSH_VERSION= osh-20091127 +OSH_VERSION= osh-20091127-p1 OSH= osh SH6= sh6 glob6 --- ../osh-20091127.orig/goto.c 2009-11-27 18:46:14.000000000 +0000 +++ ./goto.c 2009-12-04 19:42:14.000000000 +0000 @@ -67,7 +67,9 @@ #include "defs.h" #include "err.h" +#ifndef CONFIG_SUNOS static off_t offset; +#endif static bool getlabel(/*@out@*/ char *, int, size_t); static int xgetc(void); @@ -101,7 +103,9 @@ while (getlabel(label, *argv[1] & 0377, siz)) if (strcmp(label, argv[1]) == 0) { +#ifndef CONFIG_SUNOS (void)lseek(FD0, offset, SEEK_SET); +#endif return SH_TRUE; } @@ -175,9 +179,15 @@ static int xgetc(void) { +#ifndef CONFIG_SUNOS int nc; offset++; nc = getchar(); return (nc != EOF) ? nc & 0377 : EOF; +#else + unsigned char nc; + + return (read(FD0, &nc, (size_t)1) == 1) ? nc : EOF; +#endif } --- ../osh-20091127.orig/mkconfig 2009-11-27 18:46:14.000000000 +0000 +++ ./mkconfig 2009-12-04 16:49:41.000000000 +0000 @@ -75,11 +75,12 @@ >>$CONFIG_H ;; Linux) - echo '#define _XOPEN_SOURCE 600' >>$CONFIG_H - echo '#define _BSD_SOURCE' >>$CONFIG_H + echo '#define _XOPEN_SOURCE 600' >>$CONFIG_H + echo '#define _BSD_SOURCE' >>$CONFIG_H ;; SunOS) - echo '#define _XOPEN_SOURCE 600' >>$CONFIG_H + ( echo '#define CONFIG_SUNOS' ; echo ) >>$CONFIG_H + echo '#define _XOPEN_SOURCE 600' >>$CONFIG_H ;; *) # @@ -97,5 +98,5 @@ ;; esac -echo >>$CONFIG_H +echo >>$CONFIG_H echo '#endif /* !CONFIG_H */' >>$CONFIG_H --- /dev/null 2009-12-05 04:32:53.000000000 +0000 +++ ./GotoCatContinue 2009-12-05 01:53:42.000000000 +0000 @@ -0,0 +1,21 @@ +: osh or sh6 +: +: " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; +: +: " Test goto backward and forward. " +: +: >>$$'' <'' ; : >>$0'' <'' +: >>$1'' <'' ; : >>$2'' <'' ; : >>$3'' <'' +: >>$4'' <'' ; : >>$5'' <'' ; : >>$6'' <'' +: >>$7'' <'' ; : >>$8'' <'' ; : >>$9'' <'' +echo ... +if X$1 = X if { exit } fd2 -e echo usage: $0 'word1 [... [word9]]' ; false + echo .. ; goto Cat +: Continue - " ... " + echo $$: $0: $1, $2, $3, $4, $5, $6, $7, $8, $9 | \ + sed 's/^[0-9][0-9][0-9][0-9][0-9]: /?????: /' ; echo . ; exit +: Cat - " ... " + cat ; goto Continue + 1) One One One + 2) Two Two Two + 3) Three Three Three --- /dev/null 2009-12-05 04:32:53.000000000 +0000 +++ ./GotoHeadContinue 2009-12-05 02:20:03.000000000 +0000 @@ -0,0 +1,19 @@ +: osh or sh6 +: +: " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; +: +: " Test goto forward. " +: +: >>$$'' <'' ; : >>$0'' <'' +: >>$1'' <'' ; : >>$2'' <'' ; : >>$3'' <'' +: >>$4'' <'' ; : >>$5'' <'' ; : >>$6'' <'' +: >>$7'' <'' ; : >>$8'' <'' ; : >>$9'' <'' +echo ... +if X$1 = X if { exit } fd2 -e echo usage: $0 'word1 [... [word9]]' ; false + echo .. ; head -n 3 ; goto Continue + 1) One One One + 2) Two Two Two + 3) Three Three Three +: Continue - " ... " + echo $$: $0: $1, $2, $3, $4, $5, $6, $7, $8, $9 | \ + sed 's/^[0-9][0-9][0-9][0-9][0-9]: /?????: /' ; echo . --- /dev/null 2009-12-05 04:32:53.000000000 +0000 +++ ./GotoTest 2009-12-05 02:41:29.000000000 +0000 @@ -0,0 +1,9 @@ +#!/usr/bin/env osh +rm -f $$ +fd2 osh GotoCatContinue 1 2 3 4 5 6 7 8 9 >$$ ; : cat <$$ +fd2 sh6 GotoCatContinue 1 2 3 4 5 6 7 8 9 | diff $$ - >/dev/null +rm -f $$ ; if $s != 0 if { exit } fd2 -e echo GotoCatContinue: Test Failed! +fd2 osh GotoHeadContinue 1 2 3 4 5 6 7 8 9 >$$ ; : cat <$$ +fd2 sh6 GotoHeadContinue 1 2 3 4 5 6 7 8 9 | diff $$ - >/dev/null +rm -f $$ ; if $s != 0 if { exit } fd2 -e echo GotoHeadContinue: Test Failed! +: zero status