Make trap sort of work on OS X

https://github.com/fish-shell/fish-shell/issues/607
This commit is contained in:
ridiculousfish 2013-04-28 16:31:25 -07:00
parent 79f8d5c51e
commit 6496adf101

View file

@ -25,21 +25,32 @@ function trap -d 'Perform an action when the shell receives a signal'
set -l mode
set -l cmd
set -l sig
set -l shortopt
set -l longopt
set -l shortopt -o lph
set -l options
set -l longopt
if not getopt -T >/dev/null
set longopt -l print,help,list-signals
set -l shortopt lph
if not getopt -T > /dev/null
# GNU getopt
set longopt print,help,list-signals
set options -o $shortopt -l $longopt --
# Verify options
if not getopt -n type $options $argv >/dev/null
return 1
end
else
# Old getopt, used on OS X
set options $shortopt
# Verify options
if not getopt $options $argv >/dev/null
return 1
end
end
if not getopt -n type -Q $shortopt $longopt -- $argv >/dev/null
return 1
end
set -l tmp (getopt $shortopt $longopt -- $argv)
# Do the real getopt invocation
set -l tmp (getopt $options $argv)
# Break tmp up into an array
set -l opt
eval set opt $tmp
while count $opt >/dev/null