*BSD News Article 35516


Return to BSD News archive

Xref: sserve comp.unix.user-friendly:2863 comp.unix.solaris:22582 comp.unix.programmer:19885 comp.unix.misc:13827 comp.unix.aux:15438 comp.unix.bsd:14856 comp.unix.aix:43816
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!spool.mu.edu!howland.reston.ans.net!pipex!uknet!str-ccsun!sinclair
From: sinclair@dis.strath.ac.uk (Duncan Sinclair)
Newsgroups: comp.unix.user-friendly,comp.unix.solaris,comp.unix.programmer,comp.unix.misc,comp.unix.aux,comp.unix.bsd,comp.unix.aix
Subject: Re: Shell wars
Date: 6 Sep 1994 11:36:09 GMT
Organization: University of Strathclyde Computer Centre
Lines: 39
Distribution: inet
Message-ID: <34hk79$l83@rockall.cc.strath.ac.uk>
References: <33af70$8rd@usenet.INS.CWRU.Edu> <ROCKWELL.94Sep2081402@nova.umd.edu> <34d3f2$ca@sprocket.csv.warwick.ac.uk> <ROCKWELL.94Sep4164530@nova.umd.edu> <34eppt$919@sprocket.csv.warwick.ac.uk>
Reply-To: sinclair@dis.strath.ac.uk
NNTP-Posting-Host: mull.dis.strath.ac.uk

In <34eppt$919@sprocket.csv.warwick.ac.uk> cudcv@csv.warwick.ac.uk (Rob McMahon) writes:

>In article <ROCKWELL.94Sep4164530@nova.umd.edu>, rockwell@nova.umd.edu (Raul
>Deluth Miller) writes: 
>>. >lpr `set | egrep \^lpargs | cut -d= -f2-`
>>
>>. Sorry, it doesn't work.  This splits all the arguments at white
>>. space (returning 9 arguments "x" "y" "z" "x" "y" "z" "x" "y" "z"
>>. instead of 3 "x y z" "x y z" "x y z" in the example.  Using quotes:
>>
>>Sorry, I don't normally worry about that issue.  Try
>>
>>eval lpr `set | egrep \^lpargs | cut -d= -f2- | while read l; do echo
>>   \"$l\"; done`

>Still doesn't work.  I now get the 9 arguments '"x' 'y' 'z"' '"x' 'y' 'z"'
>'"x' 'y' 'z"'.

Indeed, the bourne shell has problems with preserving quoting 
in arguments passed between programs.  The "$@" hack was invented
specifically to address this problem, but it is not a total solution.

Much better to stop this {k,ba,}sh vs {t,}csh bickering and using
a shell like zsh or rc where the problem just doesn't occur.

In zsh:

  foo="x y z"
  lpargs=($foo $foo $foo)
  lpr $lpargs

Will work - no mess, no fuss.

Regards,


--
   Duncan Sinclair  |  sinclair@dis.strath.ac.uk  |  sinclair@dcs.gla.ac.uk
       ---  Would the *real* UNIX Operating System please stand up.  ---