aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions
diff options
context:
space:
mode:
authorGravatar Fabian Homborg <FHomborg@gmail.com>2016-05-23 00:49:09 +0200
committerGravatar Fabian Homborg <FHomborg@gmail.com>2016-05-23 00:49:09 +0200
commit5accc7c6c5b2234998d1a88de2dfeb1057bd5507 (patch)
tree6acb52f0cf2a1bf932c31c099f84581a98962497 /share/functions
parent60317190bd9c0abab21986f3e528f5c7359f87a6 (diff)
Fix funced's tmpfile generation on OSX
OSX mktemp... isn't great, so work around that fact.
Diffstat (limited to 'share/functions')
-rw-r--r--share/functions/funced.fish8
1 files changed, 6 insertions, 2 deletions
diff --git a/share/functions/funced.fish b/share/functions/funced.fish
index 6439e53f..8f62e96b 100644
--- a/share/functions/funced.fish
+++ b/share/functions/funced.fish
@@ -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