emacs: support BSD mktemp in emacsclient.sh (#8351)
Piping stdin to emacs alias on MacOS was breaking (--tmpdir is not
supported in BSD flavored mktemp).
Tested in MacOS 10.14 and debian:buster to confirm it still works in
linux.
Diff
1diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh
2index 26b28d495b6a63a8b88c1b0c056864a200a7e8d3..0aa8d6f40896475fd9c3e3386bbec0c1ed0de949 100755
3--- a/plugins/emacs/emacsclient.sh
4+++ b/plugins/emacs/emacsclient.sh
5@@ -20,7 +20,8 @@ _emacsfun()
6 # tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
7 if [ "$#" -ge "2" -a "$2" = "-" ]
8 then
9- tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)"
10+ tempfile="$(mktemp --tmpdir emacs-stdin-$USER.XXXXXXX 2>/dev/null \
11+ || mktemp -t emacs-stdin-$USER)" # support BSD mktemp
12 cat - > "$tempfile"
13 _emacsfun --no-wait $tempfile
14 else