Subject: bin/4994: /bin/sh argument parsing broken
To: None <>
From: Matthias Scheler <>
List: netbsd-bugs
Date: 02/15/1998 18:51:27
>Number:         4994
>Category:       bin
>Synopsis:       /bin/sh argument parsing broken
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 15 10:05:00 1998
>Originator:     Matthias Scheler
Matthias Scheler                      
>Release:        980212
System: NetBSD lyssa 1.3C NetBSD 1.3C (LYSSA) #0: Fri Feb 13 00:50:25 MET 1998 tron@lyssa:/usr/src/sys/arch/i386/compile/LYSSA i386

NetBSD-current's /bin/sh has a broken argument parsing concerning quotes.
Arguments surrounded by quotation marks end up as seperate arguments in
a shell script.

Try this shell script "foobar":
for ARG
 echo $ARG
exit 0

With 1.3C:
tron@lyssa:~>./foobar "foo bar"

With 1.3:
tron@colwyn:~/lyssa>./foobar "foo bar"
foo bar

Using "src/bin/sh/eval.c" 1.39 instead of 1.42 fixes the problem. The
ony change is this one:

@@ -333,7 +333,7 @@
        arglist.lastp = &arglist.list;
        for (argp = n->nfor.args ; argp ; argp = argp-> {
                oexitstatus = exitstatus;
-               expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+               expandarg(argp, &arglist, EXP_FULL | EXP_TILDE | EXP_RECORD);
                if (evalskip)
                        goto out;