From 3a5b7a685afc184b64ff95b2883edf2000c6bb48 Mon Sep 17 00:00:00 2001 From: "Tom \"Ravi\" Hale" Date: Fri, 24 Aug 2018 08:34:47 +0700 Subject: [PATCH] _print_path: remove unnecessary pipeline --- lib/git/status_shortcuts.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/git/status_shortcuts.sh b/lib/git/status_shortcuts.sh index ee0f804..eb81eaf 100644 --- a/lib/git/status_shortcuts.sh +++ b/lib/git/status_shortcuts.sh @@ -147,12 +147,13 @@ scmb_expand_args() { IFS="$OLDIFS" } +# Expand a variable into a (possibly relative) pathname _print_path() { - if [ "$1" = 1 ]; then - eval printf '%s' "\"\$$2\"" | sed -e "s%$(pwd)/%%" | awk '{printf("%s", $0)}' - else - eval printf '%s' "\"\$$2\"" + local pathname=$(eval printf '%s' "\"\${$2}\"") + if [ "$1" = 1 ]; then # print relative + pathname=${pathname#$PWD/} # Remove $PWD from beginning of the path fi + printf '%s' "$pathname" } # Execute a command with expanded args, e.g. Delete files 6 to 12: $ ge rm 6-12