From: martin f. krafft Date: Sun, 28 Apr 2013 06:40:49 +0000 (+0200) Subject: Implement basename in shell X-Git-Url: https://git.madduck.net/code/vcsh.git/commitdiff_plain/794f0aac?ds=sidebyside Implement basename in shell This is simple enough to warrant a re-implementation to avoid spawning subprocesses. Signed-off-by: martin f. krafft --- diff --git a/vcsh b/vcsh index b03df7a..c9c706b 100755 --- a/vcsh +++ b/vcsh @@ -12,6 +12,12 @@ # which is admittedly extremely unlikely to the point of being impossible, # this software will most likely follow suit. +basename() { + local f; f="${1##*/}" + [ -z "$2" ] || f="${f%$2}" + echo "$f" +} + SELF=$(basename $0) VERSION='1.2'