From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu Subject: Re: [9fans] dumb question From: rog@vitanuova.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-umhlbjctcemtyfkcsdzrbhrngy" Message-Id: <20020628140224.94BE6199BB@mail.cse.psu.edu> Date: Fri, 28 Jun 2002 15:08:02 +0100 Topicbox-Message-UUID: bd5938c4-eaca-11e9-9e20-41e7f4b1d025 This is a multi-part message in MIME format. --upas-umhlbjctcemtyfkcsdzrbhrngy Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit > From time to time I toy with the idea of implementing a > fully correct xargs (the Unix one doesn't quote arguments). if you're guaranteed not to have spaces or newlines in filenames, then it doesn't matter. i have a small C xargs (attached) that is probably still correct. (i think newlines are probably still banned in filenames). > I wonder if structural r.e.s can express a > complete and correct quoting algorithm. well a normal r.e. can express the rc quoting algorithm. the problem you can't just match it, you've got to translate it as well. (([^ \t']+)|'([^']|\n|'')*') the inferno shell provides primitives for quoting and unquoting lists, which are useful at times. (e.g. variables in /env are stored in quoted form rather than '\0' terminated). > what we really need is a convenient way to feed macros to > sam in a sed-like manner and somebody with the time and > inclination to develop suitable macros and package it all up. to be honest there's very little that beats the convenience of: rm `{ls | grep -v precious} (which is now broken). while i'm mentioning the inferno shell, nemo's example works nicely, as you can pass shell fragments around as words. e.g. walk /source {if {ftest -r $1} {echo $1}} which lets the shell parse the argument command before passing it on to the walk script: #!/dis/sh if {! ~ $#* 2} { echo 'usage: walk file cmd' >[1=2] exit usage } (file cmd)=$* du -a $file | getlines { (nil f) := ${split ' ' $line} $cmd $f } if du produced a quoted word for the filename, (nil f) := ${split ' ' $line} would just change to: (nil f) := ${unquote ' ' $line} it's quite nice being able to do this sort of thing, but there are tradeoffs, naturally. cheers, rog. --upas-umhlbjctcemtyfkcsdzrbhrngy Content-Type: application/octet-stream Content-Disposition: attachment; filename=xargs.c.gz Content-Transfer-Encoding: base64 H4sICDMUcTs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