Date: Wednesday, 2007-12-26, 02:40:16 UTC Patch the code to fix a "$0" parameter-substitution problem w/ the `source' command in the following interactive context: % cat >file echo \$0 == \"$0\" echo \$1 == \"$1\" ^D % source file ; : This gives the correct value for "$0". $0 == "" $1 == "" % source file arg ; : This gives an incorrect value for "$0". $0 == "0" $1 == "arg" getdolp() causes the problem by returning a NULL pointer when it should return a pointer to the empty string. This problem is not fatal, as the shell deals w/ NULL pointers from getdolp() anyway. -- Jeffrey Allen Neitzel Index: CHANGES =================================================================== --- CHANGES (revision 75) +++ CHANGES (revision 232) @@ -2,6 +2,27 @@ are marked w/ a `C:' in the details below. ------------------------------------------------------------------------------- +[osh-20070707p1]: +osh.c: + * Patch the code to fix a "$0" parameter-substitution problem w/ the + `source' command in the following interactive context: + + % cat >file + echo \$0 == \"$0\" + echo \$1 == \"$1\" + ^D + % source file ; : This gives the correct value for "$0". + $0 == "" + $1 == "" + % source file arg ; : This gives an incorrect value for "$0". + $0 == "0" + $1 == "arg" + + getdolp() causes the problem by returning a NULL pointer when it + should return a pointer to the empty string. This problem is not + fatal, as the shell deals w/ NULL pointers from getdolp() anyway. + +------------------------------------------------------------------------------- [osh-20070707]: * Added a new file, INSTALL, which contains build and install instructions. Made reference to INSTALL in Makefile and README. Index: Makefile =================================================================== --- Makefile (revision 75) +++ Makefile (revision 232) @@ -72,7 +72,7 @@ # osh-YYYYMMDD == official release # osh-current (YYYYMMDD) == development snapshot # -OSH_VERSION= osh-20070707 +OSH_VERSION= osh-20070707p1 OSH= osh SH6= sh6 glob6 Index: osh.c =================================================================== --- osh.c (revision 75) +++ osh.c (revision 232) @@ -757,7 +757,7 @@ case '5': case '6': case '7': case '8': case '9': n = c - '0'; if (DOLDIGIT(n, c) && n < dolc) - v = (n > 0) ? dolv[n] : name; + v = (n > 0) ? dolv[n] : (name != NULL) ? name : dolbuf; else v = dolbuf; break; @@ -1800,9 +1800,9 @@ /* Save and initialize any positional parameters if needed. */ sdolv = dolv; sdolc = dolc; - if (av[2] != NULL) - for (dolv = &av[1], dolc = 2; dolv[dolc] != NULL; dolc++) - ; /* nothing */ + dolv = &av[1]; + for (dolc = 0; dolv[dolc] != NULL; dolc++) + ; /* nothing */ cnt++; cmd_loop(HALT);