Re: POSIX scripting tip
[ Paul Slootman writes ]
> On Tue 03 Oct 2000, Philip Brown wrote:
> > >[someone else wrote]
> > > cp verylongfilename{,.orig}
> >
> > Anyways, since you bring up that sort of thing, I thought I'd mention
> > something folks dont often know about: POSIX SH supports something vaguely
> > similar to {,} notation in CSH.
> > [Not the odd "file isnt there yet" syntax of bash you give above.
> > I consider that a BUG, not a feature]
>
> A bug in POSIX SH?
> The feature in bash is *not* globbing. hence nothing to do with files
> that are or are not there.
Hmmm. I was considering it a bug in bash. Since I have always considered
the csh construct filename{xxx,yyy} to be globbing. Back when I learned csh
syntax, I was told that if filenameyyy did not exist, it simply would not
be expanded.
But after testing with "real" csh, it looks like csh behaves the same way.
Yeuk.
I will therefore restate my original premise to include csh, to say
The fact that the above construct does not behave in globbing fashion,
[for BOTH bash and csh] means it violates the principle of least surprise.
Therefore, a bug, IMO. "Broken as designed"
And to reply to Miguel,
Miguel Wooding (mwooding@thecity.sfsu.edu) wrote:
> Philip Brown <phil@bolthole.com> wrote:
> >
> > If you have files
> > fiftyfive fiftyfour fiftyone fiftysix fiftythree fiftytwo
>
> > $ ls fifty?(one|f*)
>
> > will result in
>
> > fiftyfive fiftyfour fiftyone
> [...]
>It doesn't seem to have "sneaked in" at all. In bash:
>$ touch ffive ffour fone fsix fthree ftwo
>$ ls
>ffive ffour fone fsix fthree ftwo
>$ ls f?(one|f*)
>bash: syntax error near unexpected token `f?(o'
I specified that the above was a feature of **POSIX** sh.
Bash is not a POSIX-compliant shell.
[hence it is a Bad Thing that /bin/sh is a link to /bin/bash]
(Mind you, I am guessing a bit that it in the actual POSIX spec.
I know it's in the KSH spec, which mostly defines POSIX-sh, and
/usr/xpg4/bin/sh
under solaris supports ls f?(xxxxx) syntax.
So it's a fairly well-founded guess ;-)
Reply to: