From e199448d724746af892a67608c88fb2ddc075c72 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 25 May 2017 18:31:36 +1200 Subject: Even terser/nicer bd() --- sh/shrc.d/bd.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'sh') diff --git a/sh/shrc.d/bd.sh b/sh/shrc.d/bd.sh index 02da6773..5b2c3d59 100644 --- a/sh/shrc.d/bd.sh +++ b/sh/shrc.d/bd.sh @@ -22,18 +22,18 @@ bd() { # Keep chopping at the current directory until it's empty or it # matches the request - while [ -n "$2" ] ; do - set -- "$1" "${2%/*}" + while set -- "$1" "${2%/*}" ; do case $2 in - (*/"$1") break ;; + */"$1") break ;; + */*) ;; + *) + printf >&2 'bd(): No match\n' + return 1 + ;; esac done # If the first argument ended up empty, we have no match - if [ -z "$2" ] ; then - printf >&2 'bd(): No match\n' - return 1 - fi shift ;; esac -- cgit v1.2.3