Commit bf52f5d5 authored by Jorge Bucaran's avatar Jorge Bucaran

fix basename polyfill

parent ed688aac
......@@ -3,27 +3,23 @@
# basename [-s suffix] <string> [string...]
#
# OVERVIEW
# osx style variable arguments basename
# variable arguments basename
function basename -d "get the filename or directory part of a path"
if test (uname) = "Darwin"
command basename $argv
else
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"
end
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"
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment