benson@seagoon.ksr.com (Benson Margulies) (08/21/87)
In an sh script -- FOO="my_command -P\"big dog\"" exec $FOO my_command gets called with argv[1] = -P"big and argv[2] = dog" whereas I want it to be called with one argument. The only work-around I found is to use sh -c $FOO I am running SunOS 3.4. Questions: is this universal? is this correct? is there a better avoidance? Benson I. Margulies Kendall Square Research Corp. harvard!ksr!benson All comments the responsibility ksr!benson@harvard.harvard.edu of the author, if anyone.
chris@mimsy.UUCP (Chris Torek) (08/21/87)
In article <182@ksr.UUCP> benson@seagoon.ksr.com (Benson Margulies) writes: [given] > FOO="my_command -P\"big dog\"" > exec $FOO >my_command gets called with argv[1] = -P"big and >argv[2] = dog" >whereas I want it to be called with one argument. Use eval exec $FOO to make sh rescan the expansion. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: seismo!mThomThomTa
guy%gorodish@Sun.COM (Guy Harris) (08/21/87)
> Questions: is this universal? Probably. The 4.3BSD Bourne shell does the same thing; it is relatively slightly modified from the V7 Bourne shell. The SunOS 3.4 Bourne shell is relatively slightly modified from the System V Bourne shell. > is this correct? Probably. > is there a better avoidance? Try eval exec $FOO The "eval" will cause the shell to rescan the input and handle the quotes the way you expect. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com
robertd@ncoast.UUCP (Rob DeMarco) (08/25/87)
In article <182@ksr.UUCP> benson@ksr.UUCP () writes: > >In an sh script -- > > FOO="my_command -P\"big dog\"" > exec $FOO Type "eval exec $FOO". eval will reevaluate quotes, variables, etc. Just like you typed the line: exec my_command -P"big dog" > >Questions: is this universal? is this correct? is there a better >avoidance? Yes, I believe so. eval is designed to overcome this. [> Rd -- North Coast Computer Resources(ncoast) - 216-781-6201 (or 781-6202) UUCP:decvax!cwruecmp!ncoast!robertd Sysop: NEODG (login "sbbs")