mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Make trap sort of work on OS X
https://github.com/fish-shell/fish-shell/issues/607
This commit is contained in:
parent
79f8d5c51e
commit
6496adf101
1 changed files with 21 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue