From cb9a2e562b540f924c1ec5dc38d495330514aa15 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Fri, 9 Jun 2017 14:05:31 +0300 Subject: [PATCH] rc: Fix calls to `mktemp` The GNU and BSD implementations differ on several points, this commit hopefully finds a middle ground. --- rc/base/lint.kak | 2 +- rc/base/spell.kak | 2 +- rc/core/doc.kak | 2 +- rc/core/grep.kak | 2 +- rc/core/make.kak | 2 +- rc/core/man.kak | 4 ++-- rc/extra/clang.kak | 2 +- rc/extra/git-tools.kak | 2 +- rc/extra/go-tools.kak | 6 +++--- rc/extra/jedi.kak | 2 +- rc/extra/racer.kak | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/rc/base/lint.kak b/rc/base/lint.kak index 30140efe..604a3f2b 100644 --- a/rc/base/lint.kak +++ b/rc/base/lint.kak @@ -8,7 +8,7 @@ decl -hidden range-specs lint_errors def lint -docstring 'Parse the current buffer with a linter' %{ %sh{ - dir=$(mktemp --tmpdir -d kak-lint.XXXXXXXX) + dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-lint.XXXXXXXX) mkfifo "$dir"/fifo printf '%s\n' "eval -no-hooks write $dir/buf" diff --git a/rc/base/spell.kak b/rc/base/spell.kak index 39744927..fd69bab1 100644 --- a/rc/base/spell.kak +++ b/rc/base/spell.kak @@ -11,7 +11,7 @@ Formats of language supported: spell %{ try %{ add-highlighter ranges 'spell_regions' } %sh{ - file=$(mktemp --tmpdir -d kak-spell.XXXXXXXX)/buffer + file=$(mktemp -d "${TMPDIR:-/tmp}"/kak-spell.XXXXXXXX)/buffer printf 'eval -no-hooks write %s\n' "${file}" printf 'set buffer spell_tmp_file %s\n' "${file}" } diff --git a/rc/core/doc.kak b/rc/core/doc.kak index 0b6ae133..478dc926 100644 --- a/rc/core/doc.kak +++ b/rc/core/doc.kak @@ -3,7 +3,7 @@ decl -docstring "name of the client in which documentation is to be displayed" \ def -hidden -params 1..2 doc-open %{ %sh{ - manout=$(mktemp --tmpdir kak-man-XXXXXX) + manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) # Those options are handled by the `man-db` implementation export MANWIDTH=${kak_window_width} diff --git a/rc/core/grep.kak b/rc/core/grep.kak index 7acb3c71..6f3ea321 100644 --- a/rc/core/grep.kak +++ b/rc/core/grep.kak @@ -8,7 +8,7 @@ def -params .. -file-completion \ -docstring %{grep []: grep utility wrapper All the optional arguments are forwarded to the grep utility} \ grep %{ %sh{ - output=$(mktemp -d -t kak-grep.XXXXXXXX)/fifo + output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-grep.XXXXXXXX)/fifo mkfifo ${output} if [ $# -gt 0 ]; then ( ${kak_opt_grepcmd} "$@" | tr -d '\r' > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & diff --git a/rc/core/make.kak b/rc/core/make.kak index 72122ca7..eb689f30 100644 --- a/rc/core/make.kak +++ b/rc/core/make.kak @@ -11,7 +11,7 @@ def -params .. \ -docstring %{make []: make utility wrapper All the optional arguments are forwarded to the make utility} \ make %{ %sh{ - output=$(mktemp --tmpdir -d kak-make.XXXXXXXX)/fifo + output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-make.XXXXXXXX)/fifo mkfifo ${output} ( eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & diff --git a/rc/core/man.kak b/rc/core/man.kak index 653fc2fc..c1d73c33 100644 --- a/rc/core/man.kak +++ b/rc/core/man.kak @@ -28,8 +28,8 @@ hook global WinSetOption filetype=(?!man).* %{ } def -hidden -params 1..2 man-impl %{ %sh{ - manout=$(mktemp --tmpdir kak-man-XXXXXX) - colout=$(mktemp --tmpdir kak-man-XXXXXX) + manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) + colout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) MANWIDTH=${kak_window_width} man "$@" > $manout retval=$? col -b -x > ${colout} < ${manout} diff --git a/rc/extra/clang.kak b/rc/extra/clang.kak index 285b4838..b4f956b2 100644 --- a/rc/extra/clang.kak +++ b/rc/extra/clang.kak @@ -11,7 +11,7 @@ def -params ..1 \ The syntaxic errors detected during parsing are shown when auto-diagnostics are enabled} \ clang-parse %{ %sh{ - dir=$(mktemp --tmpdir -d kak-clang.XXXXXXXX) + dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-clang.XXXXXXXX) mkfifo ${dir}/fifo printf %s\\n "set buffer clang_tmp_dir ${dir}" printf %s\\n "eval -no-hooks write ${dir}/buf" diff --git a/rc/extra/git-tools.kak b/rc/extra/git-tools.kak index 8a30bf95..ba8dade7 100644 --- a/rc/extra/git-tools.kak +++ b/rc/extra/git-tools.kak @@ -39,7 +39,7 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n log) filetype=git-log ;; status) filetype=git-status ;; esac - output=$(mktemp --tmpdir -d kak-git.XXXXXXXX)/fifo + output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-git.XXXXXXXX)/fifo mkfifo ${output} ( git "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & diff --git a/rc/extra/go-tools.kak b/rc/extra/go-tools.kak index 38a3d732..268067ac 100644 --- a/rc/extra/go-tools.kak +++ b/rc/extra/go-tools.kak @@ -13,7 +13,7 @@ decl -hidden completions gocode_completions def go-complete -docstring "Complete the current selection with gocode" %{ %sh{ - dir=$(mktemp --tmpdir -d kak-go.XXXXXXXX) + dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) printf %s\\n "set buffer go_complete_tmp_dir ${dir}" printf %s\\n "eval -no-hooks write ${dir}/buf" } @@ -56,7 +56,7 @@ decl -hidden str go_format_tmp_dir def -params ..1 go-format \ -docstring "go-format [-use-goimports]: custom formatter for go files" %{ %sh{ - dir=$(mktemp --tmpdir -d kak-go.XXXXXXXX) + dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) printf %s\\n "set buffer go_format_tmp_dir ${dir}" printf %s\\n "eval -no-hooks write ${dir}/buf" } @@ -87,7 +87,7 @@ decl -hidden str go_doc_tmp_dir # FIXME text escaping def -hidden -params 1..2 gogetdoc-cmd %{ %sh{ - dir=$(mktemp --tmpdir -d kak-go.XXXXXXXX) + dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) printf %s\\n "set buffer go_doc_tmp_dir ${dir}" printf %s\\n "eval -no-hooks write ${dir}/buf" } diff --git a/rc/extra/jedi.kak b/rc/extra/jedi.kak index bd147194..6d39544b 100644 --- a/rc/extra/jedi.kak +++ b/rc/extra/jedi.kak @@ -5,7 +5,7 @@ decl -docstring "colon separated list of path added to `python`'s $PYTHONPATH en def jedi-complete -docstring "Complete the current selection" %{ %sh{ - dir=$(mktemp --tmpdir -d kak-jedi.XXXXXXXX) + dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-jedi.XXXXXXXX) mkfifo ${dir}/fifo printf %s\\n "set buffer jedi_tmp_dir ${dir}" printf %s\\n "eval -no-hooks write ${dir}/buf" diff --git a/rc/extra/racer.kak b/rc/extra/racer.kak index 7c5ff9b0..ce8b5190 100644 --- a/rc/extra/racer.kak +++ b/rc/extra/racer.kak @@ -3,7 +3,7 @@ decl -hidden completions racer_completions def racer-complete -docstring "Complete the current selection with racer" %{ %sh{ - dir=$(mktemp --tmpdir -d kak-racer.XXXXXXXX) + dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-racer.XXXXXXXX) printf %s\\n "set buffer racer_tmp_dir ${dir}" printf %s\\n "eval -no-hooks %{ write ${dir}/buf }" }