functions/__scriptura_seen_script.fish (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | function __scriptura_seen_script
test (count $argv) -ne 0
or set --function argv (commandline -xpc)[2..]
argparse --stop-nonopt --move-unknown n/new -- $argv
if not set --query argv[1]
return 1
end
set --function target $SCRIPTURA_ROOT
for arg in $argv
if test "$arg" = --
break
else if path is --type dir $target/$arg
set --function target $target/$arg
else if path is --type file --perm exec $target/$arg
return 0
else
if set --query _flag_new
# the first non-directory argument is probably a script name
return 0
end
break
end
end
return 1
end
|