home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / shell / 5329 < prev    next >
Encoding:
Text File  |  1993-01-10  |  1.2 KB  |  47 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!uni-paderborn.de!urmel.informatik.rwth-aachen.de!Germany.EU.net!mcsun!fuug!kiae!demos!kaija!news-server
  3. From:  ss@loniis.spb.su (Sergey Smirnoff)
  4. Subject: Re: switch/case question under csh
  5. Reply-To: ss@loniis.spb.su
  6. Organization: St. Petersburg I of Telecom
  7. Date: Sun, 10 Jan 1993 14:15:25 GMT
  8. Message-ID: <9301101415.AA00776@loniis.spb.su>
  9. Lines: 35
  10. Sender: news-server@kaija.spb.su
  11.  
  12. In article <PATRICK.93Jan7155500@casbs.Stanford.EDU> patrick@casbs.Stanford.EDU (Patrick Goebel) writes:
  13. > In a switch statement under csh, I need a case that traps the [
  14. > character (among others).  However, all the case statements I have
  15. > tried yield a "Missing ]" error.  Here's what I've tried so far:
  16. >
  17. > case "[":
  18. > case "\[":
  19. > case \[:
  20. > case "[[]":
  21. > case "[\[]":
  22. > case "'['":
  23. > case '[':
  24. >
  25. > Does anyone know the magic incantation that quotes the [?  I need to
  26. > do the same thing with some other "trouble" characters like * and _
  27. > (underscore).
  28. >
  29. > Thanks in advance for any pointers.
  30.  
  31. Try something like this:
  32.  
  33. #!/bin/csh
  34. set a = '['
  35. set b = `echo "$a" | sed 's/\[/0x5b/'`
  36. switch ($b)
  37. case 0x5b:
  38.     echo "here is $a"
  39.     breaksw
  40. endsw
  41.  
  42. --
  43. Sergey
  44. ss@loniis.spb.su
  45.  
  46.  
  47.