From c117ee93fa38afdfd9cb51ef92748376eaa1d850 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 20 Feb 2018 05:10:25 -0800 Subject: [PATCH] tg-{export,push}.sh: avoid using "true" and "false" for testing Not guaranteed to be more efficient if "true" and "false" are also built-in, but stick with "test" and its "[" variant for checking values in order to be more consistent. Signed-off-by: Kyle J. McKay --- tg-export.sh | 46 +++++++++++++++++++++++----------------------- tg-push.sh | 18 +++++++++--------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tg-export.sh b/tg-export.sh index 75877f4..05e0130 100644 --- a/tg-export.sh +++ b/tg-export.sh @@ -27,12 +27,12 @@ forceoutput= checkout_opt=-b output= driver=collapse -flatten=false -numbered=false -strip=false +flatten= +numbered= +strip= stripval=0 smode= -allbranches=false +allbranches= binary= pl= @@ -44,26 +44,26 @@ while [ -n "$1" ]; do -h|--help) usage;; -a|--all) - allbranches=true;; + allbranches=1;; -b) branches="${branches:+$branches }$1"; shift;; --force) forceoutput=1;; --flatten) - flatten=true;; + flatten=1;; --binary) binary=1;; --numbered) - flatten=true - numbered=true;; + flatten=1 + numbered=1;; --strip*) val=${arg#*=} if [ "$val" = "--strip" ]; then - strip=true + strip=1 stripval=9999 elif [ -n "$val" ] && [ "${val#*[!0-9]}" = "$val" ]; then - strip=true - stripval=$val + strip=1 + stripval="$val" else die "invalid parameter $arg" fi;; @@ -100,22 +100,22 @@ fi [ -z "$branches" ] || [ "$driver" = "quilt" ] || die "-b works only with the quilt driver" -[ "$driver" = "quilt" ] || ! "$numbered" || +[ "$driver" = "quilt" ] || [ -z "$numbered" ] || die "--numbered works only with the quilt driver" -[ "$driver" = "quilt" ] || ! "$flatten" || +[ "$driver" = "quilt" ] || [ -z "$flatten" ] || die "--flatten works only with the quilt driver" [ "$driver" = "quilt" ] || [ -z "$binary" ] || die "--binary works only with the quilt driver" -[ "$driver" = "quilt" ] || ! "$strip" || +[ "$driver" = "quilt" ] || [ -z "$strip" ] || die "--strip works only with the quilt driver" -[ "$driver" = "quilt" ] || ! "$allbranches" || +[ "$driver" = "quilt" ] || [ -z "$allbranches" ] || die "--all works only with the quilt driver" -[ -z "$branches" ] || ! "$allbranches" || +[ -z "$branches" ] || [ -z "$allbranches" ] || die "-b conflicts with the --all option" if [ "$driver" = "linearize" ]; then @@ -127,7 +127,7 @@ if [ "$driver" = "linearize" ]; then fi fi -if [ -z "$branches" ] && ! "$allbranches"; then +if [ -z "$branches" ] && [ -z "$allbranches" ]; then # this check is only needed when no branches have been passed name="$(verify_topgit_branch HEAD)" fi @@ -313,12 +313,12 @@ quilt() _dep_tmp=$_dep - if "$strip"; then - i=$stripval + if [ -n "$strip" ]; then + i="$stripval" while [ "$i" -gt 0 ]; do [ "$_dep_tmp" = "${_dep_tmp#*/}" ] && break _dep_tmp=${_dep_tmp#*/} - i=$((i - 1)) + i="$(( $i - 1 ))" done fi @@ -328,7 +328,7 @@ quilt() dn="${dn%/*}/" [ "x$dn" = "x./" ] && dn="" - if "$flatten" && [ "$dn" ]; then + if [ -n "$flatten" ] && [ "$dn" ]; then bn="$(echo "$_dep_tmp.diff" | sed -e 's#_#__#g' -e 's#/#_#g')" dn="" fi @@ -346,7 +346,7 @@ quilt() if branch_empty "$_dep"; then echo "Skip empty patch $_dep" else - if "$numbered"; then + if [ -n "$numbered" ]; then number="$(echo $(($(cat "$playground/^number" 2>/dev/null) + 1)))" bn="$(printf "%04u-$bn" $number)" echo "$number" >"$playground/^number" @@ -466,7 +466,7 @@ driver() # Call driver on all the branches - this will happen # in topological order. -if "$allbranches" ; then +if [ -n "$allbranches" ]; then _dep_is_tgish=1 non_annihilated_branches | while read _dep; do diff --git a/tg-push.sh b/tg-push.sh index 30d9156..391ad51 100644 --- a/tg-push.sh +++ b/tg-push.sh @@ -4,26 +4,26 @@ ## Parse options -recurse_deps=true -tgish_deps_only=false +recurse_deps=1 +tgish_deps_only= dry_run= force= -push_all=false +push_all= branches= while [ -n "$1" ]; do arg="$1"; shift case "$arg" in --no-deps) - recurse_deps=false;; + recurse_deps=;; --dry-run) dry_run=--dry-run;; -f|--force) force=--force;; --tgish-only) - tgish_deps_only=true;; + tgish_deps_only=1;; -a|--all) - push_all=true;; + push_all=1;; -h|--help) echo "Usage: ${tgname:-tg} [...] push [--dry-run] [--force] [--no-deps] [--tgish-only] [-r ] [-a | --all | ...]" exit 0;; @@ -46,7 +46,7 @@ if [ -z "$remote" ]; then fi if [ -z "$branches" ]; then - if $push_all; then + if [ -n "$push_all" ]; then branches="$(non_annihilated_branches | paste -s -d " " -)" else branches="$(verify_topgit_branch HEAD)" @@ -83,7 +83,7 @@ push_branch() [ -z "$_dep_missing" ] || return 0 # if so desired omit non tgish deps - $tgish_deps_only && [ -z "$_dep_is_tgish" ] && return 0 + [ -n "$tgish_deps_only" ] && [ -z "$_dep_is_tgish" ] && return 0 # filter out plain SHA1s. These don't need to be pushed explicitly as # the patches that depend on the sha1 have it already in their ancestry. @@ -106,7 +106,7 @@ while read name && [ -n "$name" ]; do push_branch "$name" # deps but only if branch is tgish - $recurse_deps && [ -n "$_dep_is_tgish" ] && + [ -n "$recurse_deps" ] && [ -n "$_dep_is_tgish" ] && recurse_deps push_branch "$name" done <