Changeset 953 for trunk


Ignore:
Timestamp:
09/30/13 12:54:27 (11 years ago)
Author:
labetoulle
Message:

RunChecker? : use getopts built-in function to parse command line options.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/AA_RunChecker

    r952 r953  
    4545# Get arguments from command line 
    4646# ------------------------------- 
    47 while [ $# -ne 0 ] ; do 
    48   case $1 in 
    49     -h|--help|-help) 
     47while getopts :hj:p:qsu: Opt ; do 
     48  case $Opt in 
     49    h) 
    5050      echo "usage: $0 [-u user] [-q] [-j n] [-s] job_name" 
    5151      echo "       $0 [-u user] [-q] [-j n] -p config.card_path" 
     52      echo "       $0 [-u user] [-q] [-j n] -r" 
    5253      echo "" 
    5354      echo "options :" 
     
    6162      echo "       the config.card instead of the job name." 
    6263      exit 0 ;; 
    63     -j|-job-number) 
    64       NbHisto="$2" 
    65       shift 2 ;; 
    66     -p|-config-path) 
    67       ConfigPath="$2" 
     64    j) 
     65      NbHisto=${OPTARG} 
     66      ;; 
     67    p) 
    6868      fg_path=true 
    69       shift 2 ;; 
    70     -q|-quiet) 
     69      ConfigPath=${OPTARG} 
     70      ;; 
     71    q) 
    7172      fg_quiet=true 
    72       shift 1 ;; 
    73     -s|-search) 
     73      ;; 
     74    s) 
    7475      fg_search=true 
    75       shift 1 ;; 
    76     -u|-user) 
    77       TargetUsr="$2" 
    78       shift 2 ;; 
    79     -*) 
    80       $0 -h 
    81       exit ;; 
    82     *) 
    83       break ;; 
     76      ;; 
     77    u) 
     78      TargetUsr=${OPTARG} 
     79      ;; 
     80    :) 
     81      echo "$0: -"${OPTARG}" option: missing value" 
     82      exit 1 
     83      ;; 
     84    \?) 
     85      echo "$0: -"${OPTARG}" option: not supported" 
     86      exit 1 
     87      ;; 
    8488  esac 
    8589done 
    86  
    87  
    88 if ( ( ! ${fg_path} ) && [ $# -lt 1 ] ) ; then 
     90shift $(($OPTIND-1)) 
     91 
     92if ( ( ! ${fg_path} ) && ( ! ${fg_running} ) && [ $# -lt 1 ] ) ; then 
    8993  $0 -h 
    9094  exit 
Note: See TracChangeset for help on using the changeset viewer.