aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d/vr.sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-11 14:52:11 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-11 14:52:11 +1300
commit6e8c6c521ae5d60427634be01b82fe61a79f192b (patch)
tree5349fc3e9838c69dbb6fd69f0234ea921ea446ea /sh/shrc.d/vr.sh
parentFactor out zsh ENV hack into one file (diff)
downloaddotfiles-6e8c6c521ae5d60427634be01b82fe61a79f192b.tar.gz
dotfiles-6e8c6c521ae5d60427634be01b82fe61a79f192b.zip
Refactor some conditionals
Diffstat (limited to 'sh/shrc.d/vr.sh')
-rw-r--r--sh/shrc.d/vr.sh11
1 files changed, 8 insertions, 3 deletions
diff --git a/sh/shrc.d/vr.sh b/sh/shrc.d/vr.sh
index 8b35357c..c7057ec2 100644
--- a/sh/shrc.d/vr.sh
+++ b/sh/shrc.d/vr.sh
@@ -11,9 +11,14 @@ vr() {
exit 2
fi
- # Get path from first argument, strip trailing slash
+ # Get path from first argument
path=${1:-"$PWD"}
- [ "$path" = / ] || path=${path%/}
+
+ # Strip a trailing slash
+ case $path in
+ (/) ;;
+ (*) path=${path%/} ;;
+ esac
# Step into the directory
cd -- "$path" || exit
@@ -34,7 +39,7 @@ vr() {
# that is the root (bad)
while svn info >/dev/null 2>&1 ; do
root=$PWD
- [ "$root" = / ] && break
+ ! [ "$root" = / ] || break
cd .. || exit
done
if [ -n "$root" ] ; then