Don't add versions that already exist.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Feb 02 21:56:30 2009 +0000 (2009-02-02)
changeset 1200136731f6f597
parent 1199 4714cf419e98
child 1201 c9967a6e3b25
Don't add versions that already exist.

/trunk/scripts/addToolVersion.sh | 15 14 1 0 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
scripts/addToolVersion.sh
     1.1 --- a/scripts/addToolVersion.sh	Mon Feb 02 21:09:42 2009 +0000
     1.2 +++ b/scripts/addToolVersion.sh	Mon Feb 02 21:56:30 2009 +0000
     1.3 @@ -52,6 +52,7 @@
     1.4  addToolVersion() {
     1.5      local version="$1"
     1.6      local file
     1.7 +    local config_ver_option
     1.8      local exp_obs_prompt
     1.9      local deps v ver_M ver_m
    1.10      local SedExpr1 SedExpr2
    1.11 @@ -59,7 +60,19 @@
    1.12      file="config/${tool_prefix}/${tool}.in"
    1.13      v=$(echo "${version}" |"${sed}" -r -e 's/-/_/g; s/\./_/g;')
    1.14  
    1.15 -    SedExpr1="${SedExpr1}config ${cat}_V_${v}\n"
    1.16 +    config_ver_option="${cat}_V_${v}"
    1.17 +
    1.18 +    # Check for existing version: it can be legitimitate for an end-user
    1.19 +    # to try adding a new version if the one he/she wants is not listed.
    1.20 +    # But it can be the case where the version is hidden behind either one
    1.21 +    # of EXPERIMENTAL or OBSOLETE, so warn if the version is already listed.
    1.22 +    if (GREP_OPTIONS= grep -E "^config ${config_ver_option}$" "${file}" >/dev/null 2>&1); then
    1.23 +        echo "'${tool}': version '${version}' already present:"
    1.24 +        GREP_OPTIONS= grep -A3 -B0 -E "^config ${config_ver_option}$" "${file}"
    1.25 +        return 0
    1.26 +    fi
    1.27 +
    1.28 +    SedExpr1="${SedExpr1}config ${config_ver_option}\n"
    1.29      SedExpr1="${SedExpr1}    bool\n"
    1.30      SedExpr1="${SedExpr1}    prompt \"${version}"
    1.31      case "${EXP},${OBS}" in