Strange range behavior in a case statement

From: William (Reply_at_NewsGroup.Please)
Date: 09/30/03


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



Relevant Pages

  • Re: Track Changes VBA Granular information needed
    ... MsgBox "Deleted Period" ... Add more ElseIf clauses for any other punctuation you want to catch. ... one character) will show up in the table column that contains .Range.Text. ... Since Track Changes creates a Delete Bubble on the document, ...
    (microsoft.public.word.vba.beginners)
  • Re: Guy Macons adventures with ASCII character frequency
    ... > I want a list that includes the space, punctuation, ... > numerals, upper case and lower case, not just letters. ... If you want to determine relative character frequencies ... is easy to do so with a simple computer program. ...
    (sci.crypt)
  • Re: Filtering only punctuation and currency
    ... > punctuation and currency symbols. ... > of punctuation and currency symbols programatically. ... That's just not how the characters and character classes are ... But it's simple enough to loop over all the 2^16 Java chars, ...
    (comp.lang.java.programmer)
  • Wide character, portable function to parse words like OClock as one word?
    ... In English words like "O'Clock" contain an embedded character ... rules like "a quote immediately followed and preceded by an alphabet character is not treated as punctuation" must be added. ... I mean, I know what the rules are for English, but the whole point of the wide characters is to support other languages portable, and it would seem the somewhere in the LC_CTYPE information set this information should be present and accessible. ...
    (comp.lang.c)
  • Re: Filtering only punctuation and currency
    ... >> punctuation and currency symbols. ... >> of punctuation and currency symbols programatically. ... > That's just not how the characters and character classes are ... Determines if the specified character is an ISO control ...
    (comp.lang.java.programmer)