Script (sh) problem

Script (sh) problem

Post by Saila Marjut Loik » Fri, 06 May 1994 02:44:28



I'm having a minor problem with Bash. Version is 1.13.
Problem is: How to get 'case $BLA in' to match some wild-cards ?
Nice example, please tell me what I'm doing wrong in this;

---cut---
BLA='BLA BLO BLU'
case $BLA in
"BLA BLO BLI")
        echo "All three must match."
        ;;
"BLA BLO*")
        echo "First two must match."
        ;;
"*")
        echo "Anything matches."
        ;;
esac
---cut---

If I change line "BLA='DAX DIX DOX' I still don't get "Anything matches."
as output.

What I'm doin' wrong as I'm not getting as output "First two must
match." ? Thanks for any help. Please tell some pointers to related
document-files (hopefully ascii or postscript...).

Saila

 
 
 

Script (sh) problem

Post by Brand Hilt » Fri, 06 May 1994 06:13:09



Quote:>I'm having a minor problem with Bash. Version is 1.13.
>Problem is: How to get 'case $BLA in' to match some wild-cards ?
>Nice example, please tell me what I'm doing wrong in this;

>---cut---
>BLA='BLA BLO BLU'
>case $BLA in
>"BLA BLO BLI")
>        echo "All three must match."
>        ;;
>"BLA BLO*")
>        echo "First two must match."
>        ;;
>"*")
>        echo "Anything matches."
>        ;;
>esac
>---cut---

It's the quotes.  It works if you do it this way:

---cut---

BLA\ BLO\ BLU)
        echo "All three must match."
        ;;
BLA\ BLO*)
        echo "First two must match."
        ;;
*)
        echo "Anything matches."
        ;;
esac

---cut---

Note that you have to quote the blanks for
tokenization purposes.

Quote:

>If I change line "BLA='DAX DIX DOX' I still don't get "Anything matches."
>as output.

>What I'm doin' wrong as I'm not getting as output "First two must
>match." ? Thanks for any help. Please tell some pointers to related
>document-files (hopefully ascii or postscript...).

>Saila

        Brand
--
---------------------------------------------------------
The opinions expressed here are not mine.  I had my own opinions
surgically removed several years ago.  They don't belong to BNR
or Northern Telecom, either, since they let their license lapse.