[comp.unix.sysv386] SCO Unix ksh

john@beaudin.UUCP (John Beaudin) (12/29/90)

Suppose that foo and bar are 2 files in the current directory. Why will
	$ ls {foo,bar}
work, but
	$ ls {foo}
fail? The csh doesn't have this behavior. Am I expecting too much from
ksh?
-- 
My OTHER .signature is awaiting apropriate display technology

sef@kithrup.COM (Sean Eric Fagan) (12/29/90)

In article <1476@beaudin.UUCP> john@beaudin.UUCP (John Beaudin) writes:
>Suppose that foo and bar are 2 files in the current directory. Why will
>	$ ls {foo,bar}
>work, but
>	$ ls {foo}
>fail?

It looks like ksh does the same thing if the expansion "fails" as it does if
any globbing fails:  it puts, and puts (no pun intended) things back to
normal.  {foo} "fails" because there's only one thing in the list, just as
"*asdf*" would "fail" in an empty directory.

Just my $0.02; it could honestly be a bug.  (I'm just justifying the current
behaviour, something that every software maintainance engineer delights in
8-).)

-- 
Sean Eric Fagan  | "I made the universe, but please don't blame me for it;
sef@kithrup.COM  |  I had a bellyache at the time."
-----------------+           -- The Turtle (Stephen King, _It_)
Any opinions expressed are my own, and generally unpopular with others.

john@beaudin.UUCP (John Beaudin) (12/29/90)

sef@kithrup.COM (Sean Eric Fagan) writes:

>In article <1476@beaudin.UUCP> john@beaudin.UUCP (John Beaudin) writes:
>>Suppose that foo and bar are 2 files in the current directory. Why will
>>	$ ls {foo,bar}
>>work, but
>>	$ ls {foo}
>>fail?

>It looks like ksh does the same thing if the expansion "fails" as it does if
>any globbing fails:  it puts, and puts (no pun intended) things back to
>normal.  {foo} "fails" because there's only one thing in the list

I think it should work simply because there might be a script with the line
	$ cp {$*} /tmp
which would fail if only 1 arg was passed via the command line. Besides,
it works ok in csh.
Also, I've got Korn's book on ksh but can't find any reference to {} in
pathname expansion; nor in the ksh man page. Maybe it's undocumented
because it's a little buggy and not officially supported yet.
-- 
My OTHER .signature is awaiting apropriate display technology

davidsen@sixhub.UUCP (Wm E. Davidsen Jr) (12/31/90)

In article <1477@beaudin.UUCP> john@beaudin.UUCP (John Beaudin) writes:

| I think it should work simply because there might be a script with the line
| 	$ cp {$*} /tmp
| which would fail if only 1 arg was passed via the command line. Besides,
| it works ok in csh.

    That doesn't seem to work in csh, either, at least not here. Since
$* uses a blank rather than comma delimiter, the list isn't replaced.
Also, it has nothing to do with wildcard or filenames. The function in
ksh is to replicate any argument which contains a comma delimited list
enclosed in braces, with any stuff outside the braces but still in the
same argumnt.

Ex:
  $ echo a{b,c}
  ab ac
  $ echo {a,b{c,d}}
  a bc bd

  I see exactly the same output with csh.

| Also, I've got Korn's book on ksh but can't find any reference to {} in
| pathname expansion; nor in the ksh man page. Maybe it's undocumented
| because it's a little buggy and not officially supported yet.

  Maybe it's because the comma delimited list you tried didn't have a
comma in it. csh does not require the comma, nor does it allow use of
braces without quoting. If you do "ls {foo}" you will miss the file
"{foo}" and get the file "foo." 

  I don't think you should say either is "wrong," They are slightly
difirent, but in the usual case, where you want expansion of the list,
they work the same.

  Many vendors of V.4 didn't enable this feature, a large loss in my opinion.
-- 
bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
    sysop *IX BBS and Public Access UNIX
    moderator of comp.binaries.ibm.pc and 80386 mailing list
"Stupidity, like virtue, is its own reward" -me