Fix funced's tmpfile generation on OSX

OSX mktemp... isn't great, so work around that fact.
This commit is contained in:
Fabian Homborg 2016-05-23 00:49:09 +02:00
parent 60317190bd
commit 5accc7c6c5

View File

@ -87,7 +87,11 @@ function funced --description 'Edit function definition'
return 0
end
set tmpname (mktemp -t fish_funced.XXXXXXXXXX.fish)
# OSX mktemp is rather restricted - no suffix, no way to automatically use TMPDIR
# Create a directory so we can use a ".fish" suffix for the file - makes editors pick up that it's a fish file
set -q TMPDIR; or set -l TMPDIR /tmp
set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX)
set -l tmpname $tmpdir/$funcname.fish
if functions -q -- $funcname
functions -- $funcname > $tmpname
@ -120,6 +124,6 @@ function funced --description 'Edit function definition'
break
end
set -l stat $status
rm -f $tmpname >/dev/null
rm -rf $tmpdir >/dev/null
return $stat
end