diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-01-23 14:04:51 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-01-23 14:04:51 +1300 |
commit | 5981cb248e399b5594f9227b7de8f1c2b31e2c3f (patch) | |
tree | 01ec05e6d313684b4747a98ccec80090ea415337 /sh/shrc.d/vr.sh | |
parent | Fix a comment typo (diff) | |
download | dotfiles-5981cb248e399b5594f9227b7de8f1c2b31e2c3f.tar.gz dotfiles-5981cb248e399b5594f9227b7de8f1c2b31e2c3f.zip |
Work around trailing newlines in vr()
This is ugly, but a better fix isn't evident to me just now.
Diffstat (limited to 'sh/shrc.d/vr.sh')
-rw-r--r-- | sh/shrc.d/vr.sh | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sh/shrc.d/vr.sh b/sh/shrc.d/vr.sh index 1902e3ba..8b35357c 100644 --- a/sh/shrc.d/vr.sh +++ b/sh/shrc.d/vr.sh @@ -19,10 +19,16 @@ vr() { cd -- "$path" || exit # Ask Git the top level (good) - git rev-parse --show-toplevel 2>/dev/null && exit + if git rev-parse --show-toplevel 2>/dev/null ; then + printf / + exit + fi # Ask Mercurial the top level (great) - hg root 2>/dev/null && exit + if hg root 2>/dev/null ; then + printf / + exit + fi # If we can get SVN info, iterate upwards until we cannot; hopefully # that is the root (bad) @@ -32,7 +38,7 @@ vr() { cd .. || exit done if [ -n "$root" ] ; then - printf '%s\n' "$root" + printf '%s\n/' "$root" exit fi @@ -41,6 +47,9 @@ vr() { exit 1 )" + # Chop the trailing newline and slash + set -- "${1%?/}" + # Check we figured out a target, or bail [ -n "$1" ] || return |