Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!homxb!mtuxo!mtune!codas!killer!wnp From: wnp@killer.UUCP (Wolf Paul) Newsgroups: comp.unix.questions Subject: Re: bourne and korn shell incompatibilities Summary: Try this! Keywords: sh ksh Message-ID: <3181@killer.UUCP> Date: 1 Feb 88 21:51:14 GMT References: <674@pttesac.UUCP} Reply-To: wnp@killer.UUCP (Wolf Paul) Organization: The Unix(R) Connection BBS, Dallas, Tx Lines: 38 In article <674@pttesac.UUCP} vanam@pttesac.UUCP (Marnix van Ammers) writes: } }Here's an incompatibility between ksh and sh. With ksh, this fails }on both the UNIX-PC and the 3B20 if there's more than one *.c file. }Works OK with the bourne shell. } } if [ -f *.c ];then } echo "There's a C file in the current directory." } else } echo "There are no C files in the current directory." } fi } }Apparently the bourne shell permits a test such as } } if [ -f abc.c def.c xyz.c ] } }probably by throwing away the def.c and xyz.c . The korn }shell calls it a syntax error and fails the test even if }the first file exists. } }Does anyone have any recommendations as to the best way to }make these scripts palatable to the korn shell? Try this one: STRING=`echo *.c` if [ "$STRING" != "*.c" ] ; then echo "There is a C program in this dir" else echo "there is NO C program in this dir" fi I tried it both under /bin/sh and /bin/ksh and it works identically. Wolf Paul ihnp4!killer!wnp ihnp4!killer!dcs!wnp