aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-23 14:04:51 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-23 14:04:51 +1300
commit5981cb248e399b5594f9227b7de8f1c2b31e2c3f (patch)
tree01ec05e6d313684b4747a98ccec80090ea415337 /sh
parentFix a comment typo (diff)
downloaddotfiles-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')
-rw-r--r--sh/shrc.d/vr.sh15
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