tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Dealing with spaces in file names in shell scripts...

pwd and links ▻

Dealing with spaces in file names in shell scripts...

In article <35F6C9EB.B3CC83F@darwin.noris.de>,
Heiner Steven  <heiner@darwin.noris.de> wrote:
>This has nothing to do with lunacy. To preserve spaces any variable
>has to be quoted, i.e.

Not in sensible shells.

    sh$ x='foo bar'
    sh$ > $x
    sh$ ls $x
    foo not found
    bar not found

(Curiously, bash tells me "Ambiguous redirect" for the second line.
This would seem to be an incompatibility with earlier Bourne shells.)

Now try it in rc.

    rc; x = 'foo bar'
    rc; > $x
    rc; ls $x
    foo bar

In a similar vein, rc has no need for `"$@"'. To pass all arguments to
another process, just say `$*'. (If you really need `"$*"', it's spelt
`$^*', at least in the public domain rc.)

I don't really mean to vilify the Bourne shell: it's a basically good
design which has endured extremely well.  "Lunacy" was too strong a
word.  But there are one or two warts, of which this is perhaps the
major one, which have been avoided in more recently designed shells.

Tim.
--
Tim Goodwin | "The long and short of it is that its all
Cygnus UK   | pretty messy, and it will probably get a whole
Cambridge   | lot messier in the future." -- Ned Freed

Original headers:

From: tgoodwin@nan.cygnus.co.uk (Tim Goodwin)
Newsgroups: comp.unix.shell
Subject: Re: Dealing with spaces in file names in shell scripts...
Date: 14 Sep 1998 13:53:08 GMT
Organization: Cygnus Solutions Ltd, UK
Message-ID: <6tj744$gq$1@korai.cygnus.co.uk>
References: <6t42nj$h5h$1@news.tamu.edu> <6t67hb$662$1@korai.cygnus.co.uk>
  <35F6C9EB.B3CC83F@darwin.noris.de>
X-Newsreader: trn 4.0-test58 (13 May 97)

△ comp.unix.shell △

◅ Dealing with spaces in file names in shell scripts...

pwd and links ▻