From f01b67121fb5be551ed6586e71b04e5ae42cf1eb Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 6 May 2013 22:07:44 +0200 Subject: [PATCH] Improve basename() --- vcsh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) -- 2.39.2