Changeset 2142


Ignore:
Timestamp:
08/07/13 15:53:50 (8 years ago)
Author:
labetoulle
Message:

Add JobName? validation in ins_job:

  • JobName? must start with a letter;
  • it may only contain alphanumerical characters, "." and "-".

(See libIGCM #144)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modipsl/trunk/util/ins_job

    r2091 r2142  
    2929   [[ ${x_v} = 'verbose' ]] && print - "You must delete this file to update !"; 
    3030} 
     31 
     32function ins_job_Check_JobName 
     33{ 
     34  verif=${JobName##[a-zA-Z]*(?([.\-])[a-zA-Z0-9])} 
     35 
     36  if [ ${#verif} -ne 0 ] ; then 
     37    echo "################ ERROR ################" 
     38    echo "${JobName} is invalid." 
     39    echo "- JobName can only contain alphanumeric characters, \".\" and \"-\"" 
     40    echo "- JobName must start with a letter" 
     41 
     42    ((NbErr=NbErr+1)) 
     43 
     44    Status=1 
     45  else 
     46    Status=0 
     47  fi 
     48 
     49  return ${Status} 
     50} 
     51 
    3152#- 
    3253#     dirname     and      basename 
     
    110131fi 
    111132 
     133NbErr=0 
     134 
    112135#- 
    113136# Define Project ID to set up jobs header for Curie (TGCC) 
     
    191214    JobName=${config_UserChoices_JobName} 
    192215  fi 
     216 
     217  # Check JobName validity : only alphanumerical characters, "-" and "." are authorized 
     218  ins_job_Check_JobName 
     219  RetCode=$? 
     220  [[ $RetCode -gt 0 ]] && continue 
     221 
    193222  [[ ${x_v} = 'verbose' ]] && echo "JobName=${JobName}" 
    194223 
     
    294323# That's all folks 
    295324#- 
     325 
     326if [ ${NbErr} -ne 0 ] ; then 
     327  echo "################ ERROR ################" 
     328  echo "${NbErr} invalid JobName(s) found, check the log" 
     329fi 
     330 
     331 
    296332exit 0; 
Note: See TracChangeset for help on using the changeset viewer.