Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!pyramid!prls!mips!dce From: dce@mips.COM (David Elliott) Newsgroups: comp.unix.questions Subject: Re: bourne and korn shell incompatibilities Message-ID: <1450@quacky.mips.COM> Date: 1 Feb 88 16:43:39 GMT References: <674@pttesac.UUCP> <391@dplace.UUCP> Reply-To: dce@quacky.UUCP (David Elliott) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 32 Keywords: sh ksh In article <391@dplace.UUCP> djl@dplace.UUCP (Dave Lampe) writes: >First this is not an undocumented feature, it is a bug in the test >builtin in sh. The documentation specificly says "-f file", the >second filename is indeed a syntax error since it is not a valid flag. Very true. "Undocumented features", whether they are bugs or true features without documentation (like the old string operations in BSD expr) should not be expected to work. >But to solve your problem, you will have to change > if [ -f *.c ] >to > if [ -f `ls *.c | tail -1` ] >That way test will only see 1 argument. The following will also work, and it only uses builtin functions[*], so there is no fork cost: case "`echo *.c`" in '*.c') echo "no files" ;; *) echo "files found" ;; esac [*] In BSD sh, echo is not a builtin. Then again, it doesn't have test ([), either, so the above still beats the ls/tail method by 2 forks. -- David Elliott dce@mips.com or {ames,prls,pyramid,decwrl}!mips!dce