home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.shell:5282 comp.unix.programmer:5848
- Newsgroups: comp.unix.shell,comp.unix.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watserv1!mks.com!giga!eric
- From: eric@giga.mks.com (Eric Gisin)
- Subject: Re: A quoting problem.
- In-Reply-To: richb@stard.Eng.Sun.COM's message of 4 Jan 1993 20:02:03 GMT
- Message-ID: <ERIC.93Jan6204719@giga.mks.com>
- Sender: eric@mks.com (Eric Gisin)
- Organization: Mortice Kern Systems Inc., Waterloo, Ontario, CANADA
- References: <lkh5trINNvf@exodus.Eng.Sun.COM>
- Date: Thu, 7 Jan 1993 01:47:19 GMT
- Lines: 13
-
- If you need to use a variable with a list of files,
- then you have to have a delimiter (space) that is a valid filename char.
- So you can't handle a file called "Mail box".
-
- A clever trick to call the shell with -c that avoids quoting problems is:
- execl("/bin/sh", "sh", "-c", "$0 \"$@\"",
- "rm", "$$ 3", "it's", NULL);
-
- The last three arguments become the shell's $0, $1, and $2,
- and are not subject to quote interpretation.
- The command is $0 "$@", which uses $0 (rm) as the command name,
- and $1 ($$ 3) and $2 (it's) are arguments passed to rm
- without word splitting or pathname expansion.
-