Path: utzoo!mnetor!uunet!mcvax!diku!thorinn From: thorinn@diku.dk (Lars Henrik Mathiesen) Newsgroups: comp.unix.questions Subject: Re: bourne and korn shell incompatibilities Message-ID: <3638@diku.dk> Date: 4 Feb 88 10:18:44 GMT References: <674@pttesac.UUCP> <391@dplace.UUCP> <1450@quacky.mips.COM> <10423@mimsy.UUCP> Organization: DIKU, U of Copenhagen, DK Lines: 34 Keywords: sh ksh In article <10423@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >In article <1450@quacky.mips.COM> dce@mips.COM (David Elliott) writes: >Actually, if you have exactly one file, called `*.c', this will >claim there are no files. To fix this you could use > case "`echo *.c`" in > "*.c") > if [ -f "*.c" ]; then > echo files found > else > echo no files > fi;; > *) > echo files found;; > esac >although this seems like overkill, in general. I just had to invent the same thing and came up with this: if (set *.c; exec test -f $1); then echo files found else echo no files fi This works for 4.3BSD Bourne shell; on this system "test -f *.c" gives a `too many arguments' error for two or more files! I don't see why it shouldn't work with Korn shell. Note that this uses exactly one fork and one exec, and that it doesn't clobber the arguments because the "set" is used in a subshell. -- Lars Mathiesen, DIKU, U of Copenhagen, Denmark [uunet!]mcvax!diku!thorinn Institute of Datalogy -- we're scientists, not engineers.