浏览代码

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.
Eric Dobbs 4 年之前
父节点
当前提交
fc99e6db3e
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      plugins/emacs/emacsclient.sh

+ 2 - 1
plugins/emacs/emacsclient.sh

@@ -20,7 +20,8 @@ _emacsfun()
 # tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
 if [ "$#" -ge "2" -a "$2" = "-" ]
 then
-    tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)"
+    tempfile="$(mktemp --tmpdir emacs-stdin-$USER.XXXXXXX 2>/dev/null \
+                || mktemp -t emacs-stdin-$USER)" # support BSD mktemp
     cat - > "$tempfile"
     _emacsfun --no-wait $tempfile
 else