ken@turtlevax.UUCP (Ken Turkowski) (05/10/85)
In trying to make my shell scripts understand a standard help inquiry, I would like to have the csh recognize the flag "-?" , so that one might say: gobble -\? and have it echo: gobble takes the flags: -v Verbose -o <outfile> Output is directed to <outfile> rather than the default -? Prints this help message ... I have done this easily with sh, but csh is very stubborn. I have tried switch ("$flag") case case -?: case '-?': case -\?: case "-?": case "-\?": case "-\\?": case "-\\\?": case "-\\\\?": case "-\\\\\?": case '-?': case '-\?': case '-\\?': case '-\\\?': case '-\\\\?': case '-\\\\\?': endsw and none of them will match. So I offer this problem as a puzzle to the Unix community (including Bill Joy, the author). -- Ken Turkowski @ CADLINC, Menlo Park, CA UUCP: {amd,decwrl,hplabs,nsc,seismo,spar}!turtlevax!ken ARPA: turtlevax!ken@DECWRL.ARPA
ken@turtlevax.UUCP (Ken Turkowski) (05/13/85)
An the winner is: Paul Richards University of Illinois at Urbana-Champaign, Dept of Comp Sci uiucdcs!richards switch ("$flag") case '-[?]': <cmds> breaksw case '-a': <othercmds> ... endsw This is the only correct entry so far. Other entries matched -a as well as -?. One entry had the gall to have the csh invoke a Bourne shell script (is there no ethnic pride?!). This version matches -? only,using no other than the csh. I'd still be interested in any other approaches that work. But imagine that! Using brackets for quotes! Who would have ever thought that the C-shell, with its infinitely helpful programmer-oriented features, has this level of protection against matching metacharacters! :-) :*S Here's the essence of the original posting: > In trying to make my shell scripts understand a standard help inquiry, > I would like to have the csh recognize the flag "-?" , so that one might say: > gobble -\? > and have it echo: > gobble takes the flags: > -v Verbose > -o <outfile> Output is directed to <outfile> rather than the default > -? Prints this help message > ... -- Ken Turkowski @ CADLINC, Menlo Park, CA UUCP: {amd,decwrl,hplabs,nsc,seismo,spar}!turtlevax!ken ARPA: turtlevax!ken@DECWRL.ARPA