[pacman-dev] [PATCH 1/2] makepkg: clean up test usage
In a lot of places, we had the following construct: [ "$foobar" = "0" ] which is better represented by using the integer tests: [ $foobar -eq 0 ] Attempt to unify makepkg to use the latter rather than the former in all places. From here on out we should ensure anything that is set to 0, 1, etc. uses the -eq format rather than =. In addition, fix a few other test anomalies including usage of double equals. Signed-off-by: Dan McGee <dan@archlinux.org> --- scripts/makepkg.sh.in | 100 ++++++++++++++++++++++++------------------------ 1 files changed, 50 insertions(+), 50 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 1721048..c25a8d8 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -129,7 +129,7 @@ error() { # the fakeroot call, the error message will be printed by the main call. ## trap_exit() { - if [ "$INFAKEROOT" = "0" ]; then + if [ $INFAKEROOT -eq 0 ]; then echo error "$@" fi @@ -143,12 +143,12 @@ trap_exit() { clean_up() { local EXIT_CODE=$? - if [ "$INFAKEROOT" = "1" ]; then + if [ $INFAKEROOT -eq 1 ]; then # Don't clean up when leaving fakeroot, we're not done yet. return fi - if [ $EXIT_CODE -eq 0 -a "$CLEANUP" = "1" ]; then + if [ $EXIT_CODE -eq 0 -a $CLEANUP -eq 1 ]; then # If it's a clean exit and -c/--clean has been passed... msg "$(gettext "Cleaning up...")" rm -rf "$pkgdir" "$srcdir" @@ -277,7 +277,7 @@ get_downloadclient() { local i for i in "${DLAGENTS[@]}"; do local handler=$(echo $i | sed 's|::.*||') - if [ "$proto" == "$handler" ]; then + if [ "$proto" = "$handler" ]; then agent=$(echo $i | sed 's|^.*::||') break fi @@ -353,16 +353,16 @@ handledeps() { local deplist="$*" - if [ "$DEP_BIN" = "0" ]; then + if [ $DEP_BIN -eq 0 ]; then return $R_DEPS_MISSING fi - if [ "$DEP_BIN" = "1" ]; then + if [ $DEP_BIN -eq 1 ]; then # install missing deps from binary packages (using pacman -S) msg "$(gettext "Installing missing dependencies...")" local ret=0 - if [ "$ASROOT" = 0 ]; then + if [ $ASROOT -eq 0 ]; then sudo pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$? else pacman $PACMAN_OPTS -S --asdeps $deplist || ret=$? @@ -398,7 +398,7 @@ resolve_deps() { # check deps again to make sure they were resolved deplist="$(check_deps $*)" [ "$deplist" = "" ] && return $R_DEPS_SATISFIED - elif [ "$DEP_BIN" = "1" ]; then + elif [ $DEP_BIN -eq 1 ]; then error "$(gettext "Failed to install all missing dependencies.")" fi @@ -414,7 +414,7 @@ resolve_deps() { # fix flyspray bug #5923 remove_deps() { # $pkgdeps is a GLOBAL variable, set by resolve_deps() - [ "$RMDEPS" = "0" ] && return + [ $RMDEPS -eq 0 ] && return [ "$pkgdeps" = "" ] && return local dep depstrip deplist @@ -426,7 +426,7 @@ remove_deps() { msg "Removing installed dependencies..." local ret=0 - if [ "$ASROOT" = "0" ]; then + if [ $ASROOT -eq 0 ]; then sudo pacman $PACMAN_OPTS -Rns $deplist || ret=$? else pacman $PACMAN_OPTS -Rns $deplist || ret=$? @@ -686,7 +686,7 @@ run_build() { local shellopts=$(shopt -p) local ret=0 - if [ "$LOGGING" = "1" ]; then + if [ $LOGGING -eq 1 ]; then BUILDLOG="${startdir}/${pkgname}-${pkgver}-${pkgrel}-${CARCH}-build.log" if [ -f "$BUILDLOG" ]; then local i=1 @@ -736,7 +736,7 @@ run_package() { export CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST local ret=0 - if [ "$LOGGING" = "1" ]; then + if [ $LOGGING -eq 1 ]; then BUILDLOG="${startdir}/${nameofpkg}-${pkgver}-${pkgrel}-${CARCH}-package.log" if [ -f "$BUILDLOG" ]; then local i=1 @@ -785,7 +785,7 @@ tidy_install() { msg2 "$(gettext "Purging other files...")" local pt for pt in "${PURGE_TARGETS[@]}"; do - if [ "${pt}" == "${pt//\/}" ]; then + if [ "${pt}" = "${pt//\/}" ]; then find . -type f -name "${pt}" -exec rm -f -- '{}' \; else rm -f ${pt} @@ -881,7 +881,7 @@ create_package() { # write the .PKGINFO file msg2 "$(gettext "Generating .PKGINFO file...")" echo "# Generated by makepkg $myver" >.PKGINFO - if [ "$INFAKEROOT" = "1" ]; then + if [ $INFAKEROOT -eq 1 ]; then echo "# using $(fakeroot -v)" >>.PKGINFO fi echo "# $(LC_ALL=C date -u)" >>.PKGINFO @@ -1048,7 +1048,7 @@ create_xdelta() { create_srcpackage() { cd "$startdir" - if [ "$SOURCEONLY" = "2" ]; then + if [ $SOURCEONLY -eq 2 ]; then # get back to our src directory so we can begin with sources mkdir -p "$srcdir" cd "$srcdir" @@ -1084,7 +1084,7 @@ create_srcpackage() { if [ -f "$netfile" ]; then msg2 "$(gettext "Adding %s...")" "$netfile" ln -s "${startdir}/$netfile" "${srclinks}/${pkgname}" - elif [ "$SOURCEONLY" = "2" -a -f "$SRCDEST/$file" ]; then + elif [ $SOURCEONLY -eq 2 -a -f "$SRCDEST/$file" ]; then msg2 "$(gettext "Adding %s...")" "$file" ln -s "$SRCDEST/$file" "${srclinks}/${pkgname}/" fi @@ -1112,9 +1112,9 @@ create_srcpackage() { } install_package() { - [ "$INSTALL" = "0" ] && return + [ $INSTALL -eq 0 ] && return msg "$(gettext "Installing package ${pkgname} with pacman -U...")" - if [ "$ASROOT" = "0" ]; then + if [ $ASROOT -eq 0 ]; then sudo pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $? else pacman $PACMAN_OPTS -U $PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT} || exit $? @@ -1124,7 +1124,7 @@ install_package() { devel_check() { newpkgver="" # Only update pkgver if --holdver is not set - if [ "$HOLDVER" = "1" ]; then + if [ $HOLDVER -eq 1 ]; then return fi # Cannot update pkgver/pkgrel if reading PKGBUILD from pipe @@ -1453,13 +1453,13 @@ SRCDEST=${_SRCDEST:-$SRCDEST} SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined -if [ "$HOLDVER" = "1" -a "$FORCE_VER" != "" ]; then +if [ $HOLDVER -eq 1 -a "$FORCE_VER" != "" ]; then # The '\\0' is here to prevent gettext from thinking --holdver is an option error "$(gettext "\\0--holdver and --forcever cannot both be specified" )" exit 1 fi -if [ "$CLEANCACHE" = "1" ]; then +if [ $CLEANCACHE -eq 1 ]; then #fix flyspray feature request #5223 if [ -n "$SRCDEST" -a "$SRCDEST" != "$startdir" ]; then msg "$(gettext "Cleaning up ALL files from %s.")" "$SRCDEST" @@ -1495,14 +1495,14 @@ if [ -z "$BUILDSCRIPT" ]; then exit 1 fi -if [ "$INFAKEROOT" = "0" ]; then - if [ $EUID -eq 0 -a "$ASROOT" = "0" ]; then +if [ $INFAKEROOT -eq 0 ]; then + if [ $EUID -eq 0 -a $ASROOT -eq 0 ]; then # Warn those who like to live dangerously. error "$(gettext "Running makepkg as root is a BAD idea and can cause")" plain "$(gettext "permanent, catastrophic damage to your system. If you")" plain "$(gettext "wish to run as root, please use the --asroot option.")" exit 1 # $E_USER_ABORT - elif [ $EUID -gt 0 -a "$ASROOT" = "1" ]; then + elif [ $EUID -gt 0 -a $ASROOT -eq 1 ]; then # Warn those who try to use the --asroot option when they are not root error "$(gettext "The --asroot option is meant for the root user only.")" plain "$(gettext "Please rerun makepkg without the --asroot flag.")" @@ -1527,8 +1527,8 @@ else fi # check for sudo if we will need it during makepkg execution -if [ "$ASROOT" = "0" \ - -a \( "$DEP_BIN" = "1" -o "$RMDEPS" = "1" -o "$INSTALL" = "1" \) ]; then +if [ $ASROOT -eq 0 \ + -a \( $DEP_BIN -eq 1 -o $RMDEPS -eq 1 -o $INSTALL -eq 1 \) ]; then if [ ! "$(type -p sudo)" ]; then error "$(gettext "Cannot find the sudo binary! Is sudo installed?")" plain "$(gettext "Missing dependencies cannot be installed or removed as a normal user")" @@ -1559,7 +1559,7 @@ fi source "$BUILDSCRIPT" -if [ "$GENINTEG" = "1" ]; then +if [ $GENINTEG -eq 1 ]; then mkdir -p "$srcdir" cd "$srcdir" download_sources @@ -1567,7 +1567,7 @@ if [ "$GENINTEG" = "1" ]; then exit 0 # $E_OK fi -if [ "$(type -t package)" == "function" ]; then +if [ "$(type -t package)" = "function" ]; then PKGFUNC=1 fi @@ -1602,7 +1602,7 @@ if [ "$arch" = 'any' ]; then fi if ! in_array $CARCH ${arch[@]}; then - if [ "$IGNOREARCH" = "0" ]; then + if [ $IGNOREARCH -eq 0 ]; then error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgname" "$CARCH" plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT" plain "$(gettext "such as arch=('%s').")" "$CARCH" @@ -1650,8 +1650,8 @@ devel_check devel_update if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \ - -a "$FORCE" = "0" -a "$SOURCEONLY" = "0" -a "$NOBUILD" = "0" ]; then - if [ "$INSTALL" = "1" ]; then + -a $FORCE -eq 0 -a $SOURCEONLY -eq 0 -a $NOBUILD -eq 0 ]; then + if [ $INSTALL -eq 1 ]; then warning "$(gettext "A package has already been built, installing existing package...")" install_package exit $? @@ -1662,10 +1662,10 @@ if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}-${CARCH}${PKGEXT}" \ fi # Run the bare minimum in fakeroot -if [ "$INFAKEROOT" = "1" ]; then - if [ "$SPLITPKG" = "0" ]; then - if [ "$PKGFUNC" = "0" ]; then - if [ "$REPKG" = "0" ]; then +if [ $INFAKEROOT -eq 1 ]; then + if [ $SPLITPKG -eq 0 ]; then + if [ $PKGFUNC -eq 0 ]; then + if [ $REPKG -eq 0 ]; then run_build fi else @@ -1693,9 +1693,9 @@ fi msg "$(gettext "Making package: %s")" "$pkgname $pkgver-$pkgrel $CARCH ($(date))" # if we are creating a source-only package, go no further -if [ "$SOURCEONLY" != "0" ]; then +if [ $SOURCEONLY -ne 0 ]; then if [ -f "$PKGDEST/${pkgname}-${pkgver}-${pkgrel}${SRCEXT}" \ - -a "$FORCE" = "0" ]; then + -a $FORCE -eq 0 ]; then error "$(gettext "A package has already been built. (use -f to overwrite)")" exit 1 fi @@ -1705,9 +1705,9 @@ if [ "$SOURCEONLY" != "0" ]; then fi # fix flyspray bug #5973 -if [ "$NODEPS" = "1" -o "$NOBUILD" = "1" -o "$REPKG" = "1" ]; then +if [ $NODEPS -eq 1 -o $NOBUILD -eq 1 -o $REPKG -eq 1 ]; then # no warning message needed for nobuild, repkg - if [ "$NODEPS" = "1" ]; then + if [ $NODEPS -eq 1 ]; then warning "$(gettext "Skipping dependency checks.")" fi elif [ $(type -p pacman) ]; then @@ -1735,18 +1735,18 @@ umask 0022 mkdir -p "$srcdir" cd "$srcdir" -if [ "$NOEXTRACT" = "1" ]; then +if [ $NOEXTRACT -eq 1 ]; then warning "$(gettext "Skipping source retrieval -- using existing src/ tree")" warning "$(gettext "Skipping source integrity checks -- using existing src/ tree")" warning "$(gettext "Skipping source extraction -- using existing src/ tree")" - if [ "$NOEXTRACT" = "1" -a "$(ls "$srcdir" 2>/dev/null)" = "" ]; then + if [ $NOEXTRACT -eq 1 -a "$(ls "$srcdir" 2>/dev/null)" = "" ]; then error "$(gettext "The source directory is empty, there is nothing to build!")" plain "$(gettext "Aborting...")" exit 1 fi -elif [ "$REPKG" = "1" ]; then - if [ "$PKGFUNC" = "0" -a "$SPLITPKG" = "0" \ +elif [ $REPKG -eq 1 ]; then + if [ $PKGFUNC -eq 0 -a $SPLITPKG -eq 0 \ -a \( ! -d "$pkgdir" -o "$(ls "$pkgdir" 2>/dev/null)" = "" \) ]; then error "$(gettext "The package directory is empty, there is nothing to repackage!")" plain "$(gettext "Aborting...")" @@ -1758,12 +1758,12 @@ else extract_sources fi -if [ "$NOBUILD" = "1" ]; then +if [ $NOBUILD -eq 1 ]; then msg "$(gettext "Sources are ready.")" exit 0 #E_OK else # check for existing pkg directory; don't remove if we are repackaging - if [ -d "$pkgdir" -a \( "$REPKG" = "0" -o "$PKGFUNC" = "1" -o "$SPLITPKG" = "1" \) ]; then + if [ -d "$pkgdir" -a \( $REPKG -eq 0 -o $PKGFUNC -eq 1 -o $SPLITPKG -eq 1 \) ]; then msg "$(gettext "Removing existing pkg/ directory...")" rm -rf "$pkgdir" fi @@ -1772,15 +1772,15 @@ else # if we are root or if fakeroot is not enabled, then we don't use it if [ "$(check_buildenv fakeroot)" != "y" -o $EUID -eq 0 ]; then - if [ "$REPKG" = "0" ]; then + if [ $REPKG -eq 0 ]; then devel_update run_build fi - if [ "$SPLITPKG" = "0" ]; then - if [ "$PKGFUNC" = "1" ]; then + if [ $SPLITPKG -eq 0 ]; then + if [ $PKGFUNC -eq 1 ]; then run_package tidy_install - elif [ "$REPKG" = "0" ]; then + elif [ $REPKG -eq 0 ]; then tidy_install fi create_package @@ -1797,7 +1797,7 @@ else done fi else - if [ "$REPKG" = "0" -a \( "$PKGFUNC" == "1" -o "$SPLITPKG" = "1" \) ]; then + if [ $REPKG -eq 0 -a \( $PKGFUNC -eq 1 -o $SPLITPKG -eq 1 \) ]; then devel_update run_build cd "$startdir" -- 1.6.1
The goal of this fix was empty string comparisons: - if [ "$pkgname" != "" ]; then + if [ -n "$pkgname" ]; then Signed-off-by: Dan McGee <dan@archlinux.org> --- scripts/makepkg.sh.in | 38 +++++++++++++++++++------------------- 1 files changed, 19 insertions(+), 19 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c25a8d8..39e8921 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -152,7 +152,7 @@ clean_up() { # If it's a clean exit and -c/--clean has been passed... msg "$(gettext "Cleaning up...")" rm -rf "$pkgdir" "$srcdir" - if [ "$pkgname" != "" ]; then + if [ -n "$pkgname" ]; then # Can't do this unless the BUILDSCRIPT has been sourced. rm -f "${pkgname}-${pkgver}-${pkgrel}-${CARCH}.log*" fi @@ -389,7 +389,7 @@ resolve_deps() { local R_DEPS_MISSING=1 local deplist="$(check_deps $*)" - if [ "$deplist" = "" ]; then + if [ -z "$deplist" ]; then return $R_DEPS_SATISFIED fi @@ -397,7 +397,7 @@ resolve_deps() { pkgdeps="$pkgdeps $deplist" # check deps again to make sure they were resolved deplist="$(check_deps $*)" - [ "$deplist" = "" ] && return $R_DEPS_SATISFIED + [ -z "$deplist" ] && return $R_DEPS_SATISFIED elif [ $DEP_BIN -eq 1 ]; then error "$(gettext "Failed to install all missing dependencies.")" fi @@ -415,7 +415,7 @@ resolve_deps() { remove_deps() { # $pkgdeps is a GLOBAL variable, set by resolve_deps() [ $RMDEPS -eq 0 ] && return - [ "$pkgdeps" = "" ] && return + [ -z "$pkgdeps" ] && return local dep depstrip deplist deplist="" @@ -871,7 +871,7 @@ create_package() { msg "$(gettext "Creating package...")" local builddate=$(date -u "+%s") - if [ "$PACKAGER" != "" ]; then + if [ -n "$PACKAGER" ]; then local packager="$PACKAGER" else local packager="Unknown Packager" @@ -892,7 +892,7 @@ create_package() { echo "builddate = $builddate" >>.PKGINFO echo "packager = $packager" >>.PKGINFO echo "size = $size" >>.PKGINFO - if [ "$CARCH" != "" ]; then + if [ -n "$CARCH" ]; then echo "arch = $CARCH" >>.PKGINFO fi if [ "$(check_option force)" = "y" ]; then @@ -937,7 +937,7 @@ create_package() { # TODO maybe remove this at some point # warn if license array is not present or empty - if [ "$license" = "" ]; then + if [ -z "$license" ]; then warning "$(gettext "Please add a license line to your %s!")" "$BUILDSCRIPT" plain "$(gettext "Example for GPL'ed software: license=('GPL').")" fi @@ -945,7 +945,7 @@ create_package() { local comp_files=".PKGINFO" # check for an install script - if [ "$install" != "" ]; then + if [ -n "$install" ]; then msg2 "$(gettext "Adding install script...")" cp "$startdir/$install" .INSTALL comp_files="$comp_files .INSTALL" @@ -1015,7 +1015,7 @@ create_xdelta() { rm -f "$pkginfo" - if [ "$base_file" != "" ]; then + if [ -n "$base_file" ]; then msg "$(gettext "Making delta from version %s...")" "$latest_version" local delta_file="$PKGDEST/$pkgname-${latest_version}_to_$pkgver-$pkgrel-$CARCH.delta" local ret=0 @@ -1064,7 +1064,7 @@ create_srcpackage() { msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT" ln -s "${startdir}/${BUILDSCRIPT}" "${srclinks}/${pkgname}/" - if [ "$install" != "" ]; then + if [ -n "$install" ]; then if [ -f $install ]; then msg2 "$(gettext "Adding install script...")" ln -s "${startdir}/$install" "${srclinks}/${pkgname}/" @@ -1131,7 +1131,7 @@ devel_check() { if [ ! -f "./$BUILDSCRIPT" ]; then return fi - if [ "$FORCE_VER" = "" ]; then + if [ -z "$FORCE_VER" ]; then # Check if this is a svn/cvs/etc PKGBUILD; set $newpkgver if so. # This will only be used on the first call to makepkg; subsequent # calls to makepkg via fakeroot will explicitly pass the version @@ -1174,7 +1174,7 @@ devel_check() { cd ../../ fi - if [ "$newpkgver" != "" ]; then + if [ -n "$newpkgver" ]; then msg2 "$(gettext "Version found: %s")" "$newpkgver" pkgver=$newpkgver pkgrel=1 @@ -1196,7 +1196,7 @@ devel_update() { # ... # _foo=pkgver # - if [ "$newpkgver" != "" ]; then + if [ -n "$newpkgver" ]; then if [ "$newpkgver" != "$pkgver" ]; then if [ -f "./$BUILDSCRIPT" ]; then sed -i "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "./$BUILDSCRIPT" @@ -1453,7 +1453,7 @@ SRCDEST=${_SRCDEST:-$SRCDEST} SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined -if [ $HOLDVER -eq 1 -a "$FORCE_VER" != "" ]; then +if [ $HOLDVER -eq 1 -a -n "$FORCE_VER" ]; then # The '\\0' is here to prevent gettext from thinking --holdver is an option error "$(gettext "\\0--holdver and --forcever cannot both be specified" )" exit 1 @@ -1520,7 +1520,7 @@ if [ $INFAKEROOT -eq 0 ]; then sleep 1 fi else - if [ "$FAKEROOTKEY" = "" ]; then + if [ -z "$FAKEROOTKEY" ]; then error "$(gettext "Do not use the '-F' option. This option is only for use by makepkg.")" exit 1 # TODO: error code fi @@ -1551,7 +1551,7 @@ if [ ! -f "$BUILDSCRIPT" ]; then fi else crlftest=$(file $BUILDSCRIPT | grep -F 'CRLF' || true) - if [ "$crlftest" != "" ]; then + if [ -n "$crlftest" ]; then error "$(gettext "%s contains CRLF characters and cannot be sourced.")" "$BUILDSCRIPT" exit 1 fi @@ -1740,14 +1740,14 @@ if [ $NOEXTRACT -eq 1 ]; then warning "$(gettext "Skipping source integrity checks -- using existing src/ tree")" warning "$(gettext "Skipping source extraction -- using existing src/ tree")" - if [ $NOEXTRACT -eq 1 -a "$(ls "$srcdir" 2>/dev/null)" = "" ]; then + if [ $NOEXTRACT -eq 1 -a -z "$(ls "$srcdir" 2>/dev/null)" ]; then error "$(gettext "The source directory is empty, there is nothing to build!")" plain "$(gettext "Aborting...")" exit 1 fi elif [ $REPKG -eq 1 ]; then if [ $PKGFUNC -eq 0 -a $SPLITPKG -eq 0 \ - -a \( ! -d "$pkgdir" -o "$(ls "$pkgdir" 2>/dev/null)" = "" \) ]; then + -a \( ! -d "$pkgdir" -o -z "$(ls "$pkgdir" 2>/dev/null)" \) ]; then error "$(gettext "The package directory is empty, there is nothing to repackage!")" plain "$(gettext "Aborting...")" exit 1 @@ -1805,7 +1805,7 @@ else msg "$(gettext "Entering fakeroot environment...")" - if [ "$newpkgver" != "" ]; then + if [ -n "$newpkgver" ]; then fakeroot -- $0 --forcever $newpkgver -F $ARGLIST || exit $? else fakeroot -- $0 -F $ARGLIST || exit $? -- 1.6.1
Dan McGee wrote:
In a lot of places, we had the following construct: [ "$foobar" = "0" ] which is better represented by using the integer tests: [ $foobar -eq 0 ]
Attempt to unify makepkg to use the latter rather than the former in all places. From here on out we should ensure anything that is set to 0, 1, etc. uses the -eq format rather than =.
In addition, fix a few other test anomalies including usage of double equals.
In the Advanced Bash-Scripting Guide (http://tldp.org/LDP/abs/html/), they still use quotes around the variables with -eq. Both seem to work, so I wonder why? Otherwise, I have no problems with either of these tidy-up patches. Allan
Allan McRae wrote:
Dan McGee wrote:
In a lot of places, we had the following construct: [ "$foobar" = "0" ] which is better represented by using the integer tests: [ $foobar -eq 0 ]
Attempt to unify makepkg to use the latter rather than the former in all places. From here on out we should ensure anything that is set to 0, 1, etc. uses the -eq format rather than =.
In addition, fix a few other test anomalies including usage of double equals.
In the Advanced Bash-Scripting Guide (http://tldp.org/LDP/abs/html/), they still use quotes around the variables with -eq. Both seem to work, so I wonder why?
Otherwise, I have no problems with either of these tidy-up patches.
Looking into this further, it seems that the ABS guide always quotes variables. I.e. [ "$foobar" -eq 0 ]. Exceptions being $? and $#. I have tried to figure out what advantage this gives but can not find any. Allan
Allan McRae wrote:
Looking into this further, it seems that the ABS guide always quotes variables. I.e. [ "$foobar" -eq 0 ]. Exceptions being $? and $#. I have tried to figure out what advantage this gives but can not find any.
Allan
I think it's just generally good practice to quote variables because they could have spaces in them. However, in the case of the -eq operation, anything other than a single integer with no spaces will produce an error anyway. I think it's just a good habit to be in, to quote variables, even if the specific instance doesn't actually call for it. Bryan
On Sun, Jan 18, 2009 at 1:27 AM, Bryan Ischo <bji-keyword-pacman.3644cb@www.ischo.com> wrote:
Allan McRae wrote:
Looking into this further, it seems that the ABS guide always quotes variables. I.e. [ "$foobar" -eq 0 ]. Exceptions being $? and $#. I have tried to figure out what advantage this gives but can not find any.
Allan
I think it's just generally good practice to quote variables because they could have spaces in them. However, in the case of the -eq operation, anything other than a single integer with no spaces will produce an error anyway.
I think it's just a good habit to be in, to quote variables, even if the specific instance doesn't actually call for it.
I'd be fine with leaving the quotes and just changing to the '-eq' operator. We definitely don't need the quotes around "0" and "1" though. :) -Dan
participants (4)
-
Allan McRae
-
Bryan Ischo
-
Dan McGee
-
Dan McGee