argv@ucb-vax.ARPA (04/10/85)
set foo = $< if the user types "foo bar" then if($foo == "something") etc.. will die with an "expression syntax" because of the space. I thought, perhaps, that if the shell parsed the "foo" and "bar" into two separate tokens, I should be able to access $foo[0] and $foo[1] and get "foo" and "bar" respectively. This also is not the case. echo $foo[0] gives: foo bar AAAAARRRRRGGGGGGv Dan Heller (aka Frank) ucbvax!ucscc!argv {ihnp4,sun,cbosgd,decwrl}!qubix!ucscc!argv
west@sdcsla.UUCP (Larry West) (04/13/85)
In article <9845@brl-tgr.ARPA> argv@ucb-vax.ARPA writes: > >set foo = $< > >if the user types "foo bar" then > >if($foo == "something") etc.. > >will die with an "expression syntax" because of the space. >I thought, perhaps, that if the shell parsed the "foo" and >"bar" into two separate tokens, I should be able to access >$foo[0] and $foo[1] and get "foo" and "bar" respectively. >This also is not the case. All you need to do is: set foo = $< set foo = ( $foo ) the latter expands the string into separate words. For comparisions of strings, try: if ( "X$foo" == "Xsomething" ) et cetera... -- Larry West Institute for Cognitive Science (USA+619-)452-6220 UC San Diego (mailcode C-015) [x6220] ARPA: <west@nprdc.ARPA> La Jolla, CA 92093 U.S.A. UUCP: {ucbvax,sdcrdcf,decvax,ihnp4}!sdcsvax!sdcsla!west OR ulysses!sdcsla!west