From: Richard Hartmann Date: Mon, 6 May 2013 20:07:44 +0000 (+0200) Subject: Improve basename() X-Git-Url: https://git.madduck.net/code/vcsh.git/commitdiff_plain/f01b67121fb5be551ed6586e71b04e5ae42cf1eb?ds=sidebyside;hp=--cc Improve basename() --- f01b67121fb5be551ed6586e71b04e5ae42cf1eb diff --git a/vcsh b/vcsh index fb99ffb..d742cf4 100755 --- a/vcsh +++ b/vcsh @@ -13,9 +13,11 @@ # this software will most likely follow suit. basename() { - local f; f="${1##*/}" - [ -z "$2" ] || f="${f%$2}" - echo "$f" + # Implemented in shell to avoid spawning another process + local file + file="${1##*/}" + [ -z "$2" ] || file="${file%$2}" + echo "$file" } SELF=$(basename $0)