2015-08-26 15:20:13 +00:00
|
|
|
# SYNOPSIS
|
|
|
|
# basename <string> [suffix]
|
|
|
|
# basename [-s suffix] <string> [string...]
|
|
|
|
#
|
|
|
|
# OVERVIEW
|
2015-08-26 18:55:16 +00:00
|
|
|
# variable arguments basename
|
2015-08-26 15:20:13 +00:00
|
|
|
|
|
|
|
function basename -d "get the filename or directory part of a path"
|
2015-08-26 18:55:16 +00:00
|
|
|
if set -q argv[1]
|
|
|
|
set -l ext ""
|
|
|
|
switch $argv[1]
|
|
|
|
case -s
|
|
|
|
if test (count $argv) -gt 2
|
|
|
|
set ext $argv[2]
|
|
|
|
set argv $argv[3..-1]
|
|
|
|
else
|
|
|
|
echo "basename: Invalid number of arguments"
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for path in $argv
|
|
|
|
command basename "$path" "$ext"
|
2015-08-26 15:20:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|