SLG6M%USU.BITNET@WISCVM.arpa (07/13/86)
Mark Sunderlin (seismo!why_not!scsnet!sunder) writes: >(Feel free to s/bug/problem throughout this article) Gladly. One of Murphy's Law's of Computing goes something like "That's not a bug, that's a FEATURE." >Ok my fellow unix-wizards, I have come across a bug(?) I can't understand. It >seems that csh can't deal with variable assignment when the value to assign >to the variable has the meta characters [] or {} in it. However it seems >that the bourne shell has no problems with it. It is a feature of /bin/csh that it tries to process these metacharacters in variable expressions. Fortunately, however, there is a way to get around this problem without resorting to using the Bourne shell. All examples were done with csh on HP-UX V5.05. % set fix = "string[67]" % echo $fix echo: No match. (^^^^^^^^^^^^^^ this looks familiar) % echo "$fix" string[67] (^^^^^^^^^ also familiar) % set argv () autologout 60 cwd /users/barts fix string[67] ( ^^^^^^^^^^ same story here, too) history 20 home /users/barts ignoreeof mail /usr/mail/barts notify path (. /bin /usr/bin /usr/contrib/bin /usr/local/bin /etc /users/barts/cmds) prompt % shell /bin/csh status 0 term vt100 % set noglob (^^^^^^^^^^^ see explanation following this example) % echo $fix string[67] (^^^^^^^^^ no more problem!) % unset noglob (^^^^^^^^^^^^^ see explanation) % set fix = `grep define fix10` % echo $fix #define key_f10 CUR #define key_f2 CUR #define key_f3 CUR #define key_f4 CUR #de fine key_f5 CUR #define key_f6 CUR #define key_f7 CUR #define key_f8 CUR #define key_f9 CUR #define key_home CUR (^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ more familiar stuff) % set noglob % set fix = `grep define fix10` (^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ we must compute this anew with noglob set; problems creep in at this step) % echo $fix #define key_f10 CUR Strings[67] #define key_f2 CUR Strings[68] #define key_f3 CU R Strings[69] #define key_f4 CUR Strings[70] #define key_f5 CUR Strings[71] #def ine key_f6 CUR Strings[72] #define key_f7 CUR Strings[73] #define key_f8 CUR Str ings[74] #define key_f9 CUR Strings[75] #define key_home CUR Strings[76] (^^^^ gee, this looks just like the Bourne shell!) To quote the manual entry for csh(1) on my system: "If [the csh variable noglob is] set, filename expansion is inhibited. This is most useful in shell scripts which are not dealing with filenames, or after a list of filenames has been obtained and further expansions are not desirable." Unfortunately, noglob has its own problems, as it disables *all* filename expansion, so things like "ls *.out" will result in error messages even if you have an a.out file on your current directory. --David Barts Utah State University, Logan, Utah, USA Bitnet: SLG6M@USU.BITNET ARPAnet: slg6m%usu.bitnet@wiscvm.arpa AT&T: 801-753-2952 USPS: 654 1/2 E 800 N / Logan, UT 84321