home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / shell / 5282 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.2 KB

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