bourne and korn shell incompatibilities

Chris Torek chris at mimsy.UUCP
Tue Feb 2 09:26:52 AEST 1988


In article <1450 at quacky.mips.COM> dce at mips.COM (David Elliott) writes:
>The following will also work....
>
>	case "`echo *.c`" in
>		'*.c')
>			echo "no files"
>			;;
>		*)
>			echo "files found"
>			;;
>	esac

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.

Thinking about a shell with built-in exception handling,
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list