Mandriva Expert
The place where your Mandriva Linux system finds support

case in bash script

+/- details
User javiermarcon
Incident Number 71257
Date 2003/09/30 14:45
Status Incident closed
Paid No

Product 9.1 (Bamboo)
Architecture x86_32
Scope Administration

Products owned
Community Support question - to convert into a paid question, click here

Lines in bold below have not yet been seen by the customer - those in blue are from the customer

Username : Date : Action : Comments [ close all ]    
 
javiermarcon : 30/09/03 02:45 PM : Incident created
-   Hello I made a bash script, with a ccase, but it doesn't select the '? )' option. Here is the script:

#!/bin/bash

case $1 in
'pepe' )
valor='10k'
valor2='15k' ;;
'pepa' )
valor='12k'
valor2='17k' ;;
'pepeon' )
valor='20k'
valor2='25k' ;;
? )
echo 'Hay que elegir algo'
exit 0
esac
echo '$1 $valor $valor2'

The problem is that it never gives me the error echo 'Hay que elegir algo', if i don't put any of the values that the case have. How can i fix it to give me that echo message when I put an opion that is not pepe, pepa or pepon?

Thanks.

 
nexus_la : 06/10/03 07:41 PM : More info requested
-   Try this variant(replace ? with *):

#!/bin/bash
...
valor='20k'
valor2='25k' ;;
* )
echo 'Hay que elegir algo'
exit 0
...

 
 
javiermarcon : 08/10/03 03:23 PM : Incident closed
-  



This Incident is closed. It can not be edited anymore. You can create a new one by signing up/logging in your Mandriva Expert account.

  Mandriva  |  Contact  |  Legal  |  Privacy  |  Careers