home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- 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
- From: ss@loniis.spb.su (Sergey Smirnoff)
- Subject: Re: switch/case question under csh
- Reply-To: ss@loniis.spb.su
- Organization: St. Petersburg I of Telecom
- Date: Sun, 10 Jan 1993 14:15:25 GMT
- Message-ID: <9301101415.AA00776@loniis.spb.su>
- Lines: 35
- Sender: news-server@kaija.spb.su
-
- In article <PATRICK.93Jan7155500@casbs.Stanford.EDU> patrick@casbs.Stanford.EDU (Patrick Goebel) writes:
- > In a switch statement under csh, I need a case that traps the [
- > character (among others). However, all the case statements I have
- > tried yield a "Missing ]" error. Here's what I've tried so far:
- >
- > case "[":
- > case "\[":
- > case \[:
- > case "[[]":
- > case "[\[]":
- > case "'['":
- > case '[':
- >
- > Does anyone know the magic incantation that quotes the [? I need to
- > do the same thing with some other "trouble" characters like * and _
- > (underscore).
- >
- > Thanks in advance for any pointers.
-
- Try something like this:
-
- #!/bin/csh
- set a = '['
- set b = `echo "$a" | sed 's/\[/0x5b/'`
- switch ($b)
- case 0x5b:
- echo "here is $a"
- breaksw
- endsw
-
- --
- Sergey
- ss@loniis.spb.su
-
-
-