From 7bbaa4d7b324aba04594fc64a09b353000b4d9fe Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 12 Jan 2015 15:27:33 -0500 Subject: [PATCH] Avoid duplicate code in script Change-Id: Ia40f8fd676a7e2c302f06efa4ccf9fb77dc6dfc9 Signed-off-by: Marc Khouzam Reviewed-on: https://git.eclipse.org/r/39421 Tested-by: Hudson CI Reviewed-by: Simon Marchi --- .../scripts/download-build-gdb.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/scripts/download-build-gdb.sh b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/scripts/download-build-gdb.sh index efa269fc535..28eb3fccc13 100755 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/scripts/download-build-gdb.sh +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/scripts/download-build-gdb.sh @@ -1,6 +1,6 @@ #!/bin/bash -# * Copyright (c) 2014 Ericsson and others. +# * Copyright (c) 2015 Ericsson and others. # * All rights reserved. This program and the accompanying materials # * are made available under the terms of the Eclipse Public License v1.0 # * which accompanies this distribution, and is available at @@ -20,7 +20,7 @@ base_dir="${default_base_dir}" default_jlevel="4" jlevel="${default_jlevel}" -# Default versions (for when "all" is used) +# Supported versions default_versions="6.6 6.7.1 6.8 7.0.1 7.1 7.2 7.3.1 7.4.1 7.5.1 7.6.2 7.7.1 7.8.1" # Is set to "echo" if we are doing a dry-run. @@ -66,8 +66,11 @@ function echo_header() { # # $1: version number function check_supported() { - case "$version" in - "6.6"|"6.7.1"|"6.8"|"7.0.1"|"7.1"|"7.2"|"7.3.1"|"7.4.1"|"7.5.1"|"7.6.2"|"7.7.1"|"7.8.1") + local supported_pattern="@(${default_versions// /|})" + + shopt -s extglob + case "$version" in + ${supported_pattern}) # Supported, do nothing. ;; *) @@ -168,12 +171,8 @@ function configure_gdb() { # Let the user specify some CFLAGS cflags="${cflags} ${CFLAGS}" - # The ${dryrun} trick doesn't work here, because of the env var. - if [ -z "${dryrun}" ]; then - CFLAGS="${cflags}" ./configure --prefix="${install_dir}/gdb-${version}" - else - ${dryrun} CFLAGS="\"${cflags}\"" ./configure --prefix="${install_dir}/gdb-${version}" - fi + # Need to use eval to allow the ${dryrun} trick to work with the env var command at the start. + eval ${dryrun} 'CFLAGS="${cflags}" ./configure --prefix="${install_dir}/gdb-${version}"' ${dryrun} popd }