From 8f4a1533f3eebcd278ccc9fdbd414dc183202aaf Mon Sep 17 00:00:00 2001 From: Julien Malik Date: Thu, 3 Sep 2015 18:17:03 +0200 Subject: [PATCH] Fix tests which were badly written. Use double brackets consistently --- install_yunohostv2 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/install_yunohostv2 b/install_yunohostv2 index dac3403..b2c9a8d 100755 --- a/install_yunohostv2 +++ b/install_yunohostv2 @@ -54,7 +54,7 @@ $1 this_script_path() { # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in local SOURCE="${BASH_SOURCE[0]}" - while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + while [[ -h "$SOURCE" ]]; do # resolve $SOURCE until the file is no longer a symlink local DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" SOURCE="$(readlink "$SOURCE")" [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located @@ -64,7 +64,7 @@ this_script_path() { } ensure_root() { - if [ "$(id -u)" != "0" ] ; + if [[ "$(id -u)" != "0" ]] ; then return 1 fi @@ -121,7 +121,7 @@ set_domain() { # Configure hostname to yunohost.yunohost.org if not already set # NOTE: This is done also during postinstall "to avoid amavis bug" # so we might not need it here - [ "$(hostname -d > /dev/null 2>&1)" != "" ] || hostname yunohost.yunohost.org > /dev/null 2>&1 + [[ "$(hostname -d > /dev/null 2>&1)" != "" ]] || hostname yunohost.yunohost.org > /dev/null 2>&1 } confirm_installation() { @@ -148,7 +148,7 @@ setup_package_source() { echo "deb http://repo.yunohost.org/ megusta main" > $CUSTOMAPT # Also add repositories for 'testing' and/or 'unstable' if the script has been called with those arguments - if [ $# -gt 0 ]; then + if [[ "$#" > "0" ]]; then if [[ "$1" == "test" ]] || [[ "$1" == "testing" ]] ; then echo "deb http://repo.yunohost.org/ testing main" >> $CUSTOMAPT fi @@ -170,7 +170,7 @@ apt_update() { } register_debconf() { - if [ $(lsb_release -c | awk '{print $2}') = jessie ]; + if [[ $(lsb_release -c | awk '{print $2}') == jessie ]]; then debconf-set-selections $(this_script_path)/debconfjessie else @@ -196,11 +196,11 @@ workaround_avahi_installation() { # consecutive uids). # Return without error if avahi already exists - [ $(id avahi > /dev/null 2>&1) ] || return 0 + id avahi > /dev/null 2>&1 || return 0 # Get a random unused uid between 500 and 999 (system-user) local avahi_id=$((500 + $RANDOM % 500)) - while [ $(cat /etc/passwd | cut -d ':' -f 3 | grep $avahi_id) ] ; + while ! cat /etc/passwd | cut -d ':' -f 3 | grep -q $avahi_id ; do avahi_id=$((500 + $RANDOM % 500)) done @@ -263,7 +263,7 @@ Do you want to proceed with YunoHost post-installation now? /usr/bin/yunohost tools postinstall local POSTINSTALL_EXIT_CODE="$?" - while [ "$POSTINSTALL_EXIT_CODE" -ne 0 ] ; + while [[ "$POSTINSTALL_EXIT_CODE" != "0" ]] ; do local text_retry=" Yunohost post-installation has failed.