shell scripts and comand arguments
Frank Shute
frank at esperance-linux.co.uk
Mon Jun 2 10:15:25 BST 2003
On Mon, Jun 02, 2003 at 09:07:32AM +0100, John Rochester wrote:
>
>
> On Sunday, Jun 1, 2003, at 14:53 Europe/London, Jonathan Belson wrote:
>
> >Hiya
> >
> >
> >I was making some tweaks to a script I wrote to 'mhonarc' freebsd-*
> >mailing lists, when I ran into a problem with substitutions. Here's
> >an example:
> >
> >
> >list="freebsd-ports"
> >title="$list archive"
> >args="-title \"$title\" -add . -outdir ."
> >mhonarc $args
> >
> >
> >$args expands to
> >
> > -title "freebsd-ports archive" -add . -outdir .
> >
> >which is what you'd expect, but mhonarc sees
> >
> > -title "free-ports
> >
> >followed by
> >
> > archive"
> >
> >which confuses it no end.
> >
> >Is there a simple solution to this problem or must I do it another way?
>
> You need sh to pass this through another parsing stage to catch the
> quotes.
>
> Change the final line to
>
> eval mhonarc "$args"
>
> and it should work.
>
I've tested this the way Jonathan wrote it, the way I wrote it and the
way you've written it, but s/echo/mhonarc/
The way Jonathan wrote it, it seems to work, & the way I wrote it, it
seems to work:
$ ./test
-title "freebsd-ports archive" -add . -outdir .
but the way you wrote it gives me:
$ ./test
-title freebsd-ports archive -add . -outdir .
Could it be less to do with the shell & more to do with how mhonarc
itself handles commandline args? (Which is probably a perl thing,
having had a brief look at it's Makefile)
--
Frank
*-*-*-*-*-*-*-*-*-*-*
Boroughbridge.
Tel: 01423 323019
---------
PGP keyID: 0xC0B341A3
*-*-*-*-*-*-*-*-*-*-*
http://www.esperance-linux.co.uk/
The Dow explodes with Baghdad!
I love it when a plan comes together!
- Seen on Slashdot
More information about the Ukfreebsd
mailing list