From c67d35f8a5a2c3b7feac8e8f5416f4415f9d0d77 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 23 Dec 2013 18:40:41 -0500 Subject: git-rewrite-branch: change verbose() to use printf instead of interpolation --- git-rewrite-branch | 28 ++++++++++++++++------------ 1 file 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" -- cgit v1.1-4-g5e80