CSH Help -- I don't get it ...

kai at uicsrd.csrd.uiuc.edu kai at uicsrd.csrd.uiuc.edu
Mon Aug 8 10:12:00 AEST 1988


>#!/bin/csh
>set x=stuff_and_more
>echo try one:
>if "$x" =~ "stuff*" echo yes
>
>echo try two:
>alias x 'if "$x" =~ "stuff*" echo yes'
>x
>
>echo try three:
>alias x 'if "$x" =~ "stuff"* echo yes'
>x

Instead, try:

	#!/bin/csh -f
	set x = "stuff_and_more"
	echo "try one:"
	if ( "$x" =~ stuff* ) echo yes
	
	echo "try two:"
	alias x 'if ( "$x" =~ stuff* ) echo yes'
	x


I didn't know C-shell's if command worked at all without parens.

Your problem was the double quotes.  Pattern matching in C shell doesn't work
when the *pattern* is surrounded with double quotes.

Patrick Wolfe  (pwolfe at kai.com,  kailand!pwolfe)



More information about the Comp.unix.wizards mailing list