Strange range behavior in a case statement
From: William (Reply_at_NewsGroup.Please)
Date: 09/30/03
- Next message: Maurizio: "Grep Output"
- Previous message: Andreas Kahari: "Re: ksh'93 getopts --longoptions"
- Next in thread: Stephane CHAZELAS: "Re: Strange range behavior in a case statement"
- Reply: Stephane CHAZELAS: "Re: Strange range behavior in a case statement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 30 Sep 2003 09:36:19 -0500
Just wondering if someone can tell me if this behavior appears in other
versions of bash or bourne shell:
I wrote a case statement which needed to test for a range of
characters including some contiguous punctionation. It went
something like this (extracted from original script):
#!/bin/sh
stty -echo raw
while : ; do
GP_CH=`\dd bs=1 count=1 2> /dev/null`
case "$GP_CH" in [!!-~] ) break ;; esac # Problem area
GP_PW=${GP_PW}$GP_CH ; $EcHo "*\c"
GP_PWM="${GP_PWM}*"
done
stty -raw echo
echo "$GP_PW"
echo "$GP_PWM"
It's supposed to accept any character greater than a
space and less than a Del.
That worked fine on various bourne-like shells under
several versions of AIX, Solaris, HP-UX. It also
worked on SuSE Linux. It did NOT work at all on
RH Linux 9. Every character caused the loop to break.
After some experiments, I determined that I could
not specify a range using punctuation symbols (any
punctuation, as far as I could tell); only [a-z],
[A-Z] or [0-9] seem to work.
I ended up testing for each punctuation character
individually (escaping a lot of them). Very tedious.
Is this a new standard "feature"? -Wm
- Next message: Maurizio: "Grep Output"
- Previous message: Andreas Kahari: "Re: ksh'93 getopts --longoptions"
- Next in thread: Stephane CHAZELAS: "Re: Strange range behavior in a case statement"
- Reply: Stephane CHAZELAS: "Re: Strange range behavior in a case statement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|