aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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