The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 10-18-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,408
Try using a while loop to process the parameters, e.g...
Code:
while [[ $# -gt 0 ]]
do
    case $1 in
        -product) export PRODUCT=$2 ; shift ;;
        -version) export VERSION=$2 ; shift ;;
               *) echo invalid option ; exit 1 ;;
    esac
    shift
done
Note that options with arguments require additional shifts.