diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-12-23 18:40:41 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-12-23 18:40:41 -0500 |
commit | c67d35f8a5a2c3b7feac8e8f5416f4415f9d0d77 (patch) | |
tree | 9ab2d2c9c36d3c78359023859bd03937bcd8176f | |
parent | 7e2d43405b2de73068a4ac367639ee39944cac64 (diff) |
git-rewrite-branch: change verbose() to use printf instead of interpolation
-rwxr-xr-x | git-rewrite-branch | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/git-rewrite-branch b/git-rewrite-branch index 390170b..c7b3e9f 100755 --- a/git-rewrite-branch +++ b/git-rewrite-branch @@ -52,8 +52,8 @@ panic() { exit 1 } -# Usage: verbose arg1 arg2... -# Print the arguments, but only if in verbose mode. +# Usage: verbose format arg1 arg2... +# Print the printf string, but only if in verbose mode. # Verbose mode works by redefining this function during option parsing if -v is # encountered. verbose() { @@ -118,7 +118,11 @@ main() { --no-tag) hastag=false; tag='git-rewrite-id'; shift 1 ;; -h) usage; return 0;; -v) - verbose() { echo "$*"; } + verbose() { + local fmt=$1 + shift + printf "${fmt}\n" "$@" + } shift ;; *) break;; @@ -200,17 +204,17 @@ main() { local commonish="$(c2c "$obranch" "$wbranch" "$obranch")" cmd=(git rebase --onto "$obranch" "$commonish" "$wbranch") - verbose - verbose " o---o---o $obranch" + verbose '' + verbose ' o---o---o %s' "$obranch" verbose ' :' - verbose " o---o---o---o---o $ibranch" + verbose ' o---o---o---o---o %s' "$ibranch" verbose ' \ :' - verbose ' `-C---o---o '"$wbranch" - verbose - verbose " C = $commonish" - verbose - verbose " ${cmd[*]}" - verbose + verbose ' `-C---o---o %s' "$wbranch" + verbose '' + verbose ' C = %s' "$commonish" + verbose '' + verbose ' %s' "$(printf '%q ' "${cmd[@]}")" + verbose '' "${cmd[@]}" git checkout "$obranch" |