Commit bf52f5d5 authored by Jorge Bucaran's avatar Jorge Bucaran

fix basename polyfill

parent ed688aac
...@@ -3,27 +3,23 @@ ...@@ -3,27 +3,23 @@
# basename [-s suffix] <string> [string...] # basename [-s suffix] <string> [string...]
# #
# OVERVIEW # OVERVIEW
# osx style variable arguments basename # variable arguments basename
function basename -d "get the filename or directory part of a path" function basename -d "get the filename or directory part of a path"
if test (uname) = "Darwin" if set -q argv[1]
command basename $argv set -l ext ""
else switch $argv[1]
if set -q argv[1] case -s
set -l ext "" if test (count $argv) -gt 2
switch $argv[1] set ext $argv[2]
case -s set argv $argv[3..-1]
if test (count $argv) -gt 2 else
set ext $argv[2] echo "basename: Invalid number of arguments"
set argv $argv[3..-1] return 1
else end
echo "basename: Invalid number of arguments" end
return 1 for path in $argv
end command basename "$path" "$ext"
end
for path in $argv
command basename "$path" "$ext"
end
end end
end 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