From 05eac418f012b9d92f1955cab3d19a5cb9aef760 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 27 May 2017 21:24:17 +1200 Subject: Add safety to bd() Handle case if PWD does not start with a slash--a big "Shouldn't Happen", but easy enough to be worth handling, since it would loop infinitely otherwise --- sh/shrc.d/bd.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh index 1b253e3d..29bde513 100644 --- a/sh/shrc.d/bd.sh +++ b/sh/shrc.d/bd.sh @@ -28,7 +28,8 @@ bd() { case $2 in */"$1"|'') break ;; */) set -- "$1" "${2%/}" ;; - *) set -- "$1" "${2%/*}" ;; + */*) set -- "$1" "${2%/*}" ;; + *) set -- "$1" '' ;; esac done shift -- cgit v1.2.3