From 009eb80ca0e606babd2d9b735faa7ec7643a046e Mon Sep 17 00:00:00 2001 From: codesoap Date: Sun, 9 Jun 2019 11:45:59 +0200 Subject: [PATCH 1/4] Fix tools using fifos for OpenBSD Without these changes, kak would hang on the corresponding commands, displaying a 'waiting for shell command to finish' message. --- rc/tools/clang.kak | 4 ++-- rc/tools/git.kak | 2 +- rc/tools/grep.kak | 4 ++-- rc/tools/lint.kak | 4 ++-- rc/tools/make.kak | 2 +- rc/tools/python/jedi.kak | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rc/tools/clang.kak b/rc/tools/clang.kak index 678181bf..e0f90299 100644 --- a/rc/tools/clang.kak +++ b/rc/tools/clang.kak @@ -36,7 +36,7 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are # not hang while clang is running. As completions references a cursor # position and a buffer timestamp, only valid completions should be # displayed. - ( + {( case ${kak_opt_filetype} in c) ft=c ;; cpp) ft=c++ ;; @@ -100,7 +100,7 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are printf %s\\n "set-option 'buffer=${kak_buffile}' clang_flags ${kak_timestamp} ${flags} set-option 'buffer=${kak_buffile}' clang_errors ${kak_timestamp} ${errors}" | kak -p ${kak_session} - ) > /dev/null 2>&1 < /dev/null & + ) & } > /dev/null 2>&1 < /dev/null } } diff --git a/rc/tools/git.kak b/rc/tools/git.kak index d99de777..47e3d59a 100644 --- a/rc/tools/git.kak +++ b/rc/tools/git.kak @@ -45,7 +45,7 @@ Available commands:\n add\n rm\n blame\n commit\n checkout\n diff\n hide- esac output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-git.XXXXXXXX)/fifo mkfifo ${output} - ( git "$@" > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & + ( git "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null printf %s "evaluate-commands -try-client '$kak_opt_docsclient' %{ edit! -fifo ${output} *git* diff --git a/rc/tools/grep.kak b/rc/tools/grep.kak index 9e6ed5ab..33d5be38 100644 --- a/rc/tools/grep.kak +++ b/rc/tools/grep.kak @@ -11,9 +11,9 @@ All the optional arguments are forwarded to the grep utility} \ 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 & + ( ${kak_opt_grepcmd} "$@" | tr -d '\r' > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null else - ( ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & + ( ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null fi printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{ diff --git a/rc/tools/lint.kak b/rc/tools/lint.kak index de120df2..d39e7d32 100644 --- a/rc/tools/lint.kak +++ b/rc/tools/lint.kak @@ -28,7 +28,7 @@ define-command lint -docstring 'Parse the current buffer with a linter' %{ hook -always -once buffer BufCloseFifo .* %{ nop %sh{ rm -r '$dir' } } }" - { # do the parsing in the background and when ready send to the session + {{ # do the parsing in the background and when ready send to the session eval "$kak_opt_lintcmd '$dir'/${filename}" | sort -t: -k2,2 -n > "$dir"/stderr @@ -78,7 +78,7 @@ define-command lint -docstring 'Parse the current buffer with a linter' %{ } ' > "$dir"/fifo - } >/dev/null 2>&1 /dev/null 2>&1 ${output} 2>&1 ) > /dev/null 2>&1 < /dev/null & + ( eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{ edit! -fifo ${output} -scroll *make* diff --git a/rc/tools/python/jedi.kak b/rc/tools/python/jedi.kak index 5f28ba64..05b41598 100644 --- a/rc/tools/python/jedi.kak +++ b/rc/tools/python/jedi.kak @@ -19,7 +19,7 @@ define-command jedi-complete -docstring "Complete the current selection" %{ evaluate-commands %sh{ dir=${kak_opt_jedi_tmp_dir} printf %s\\n "evaluate-commands -draft %{ edit! -fifo ${dir}/fifo *jedi-output* }" - ( + {( cd $(dirname ${kak_buffile}) header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" @@ -32,7 +32,7 @@ define-command jedi-complete -docstring "Complete the current selection" %{ ) printf %s\\n "evaluate-commands -client ${kak_client} %~echo completed; set-option %{buffer=${kak_buffile}} jedi_completions ${header} ${compl}~" | kak -p ${kak_session} rm -r ${dir} - ) > /dev/null 2>&1 < /dev/null & + ) & } > /dev/null 2>&1 < /dev/null } } From 6c05e6e0f81243ec503a3de78cf36b5dc798cb1c Mon Sep 17 00:00:00 2001 From: codesoap Date: Sun, 9 Jun 2019 13:24:30 +0200 Subject: [PATCH 2/4] Don't create subshells when unnecessary --- rc/tools/clang.kak | 4 ++-- rc/tools/git.kak | 2 +- rc/tools/grep.kak | 4 ++-- rc/tools/make.kak | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rc/tools/clang.kak b/rc/tools/clang.kak index e0f90299..fc8f5052 100644 --- a/rc/tools/clang.kak +++ b/rc/tools/clang.kak @@ -36,7 +36,7 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are # not hang while clang is running. As completions references a cursor # position and a buffer timestamp, only valid completions should be # displayed. - {( + {{ case ${kak_opt_filetype} in c) ft=c ;; cpp) ft=c++ ;; @@ -100,7 +100,7 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are printf %s\\n "set-option 'buffer=${kak_buffile}' clang_flags ${kak_timestamp} ${flags} set-option 'buffer=${kak_buffile}' clang_errors ${kak_timestamp} ${errors}" | kak -p ${kak_session} - ) & } > /dev/null 2>&1 < /dev/null + } & } > /dev/null 2>&1 < /dev/null } } diff --git a/rc/tools/git.kak b/rc/tools/git.kak index 47e3d59a..c2434819 100644 --- a/rc/tools/git.kak +++ b/rc/tools/git.kak @@ -45,7 +45,7 @@ Available commands:\n add\n rm\n blame\n commit\n checkout\n diff\n hide- esac output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-git.XXXXXXXX)/fifo mkfifo ${output} - ( git "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null + { git "$@" > ${output} 2>&1 & } > /dev/null 2>&1 < /dev/null printf %s "evaluate-commands -try-client '$kak_opt_docsclient' %{ edit! -fifo ${output} *git* diff --git a/rc/tools/grep.kak b/rc/tools/grep.kak index 33d5be38..1e105b73 100644 --- a/rc/tools/grep.kak +++ b/rc/tools/grep.kak @@ -11,9 +11,9 @@ All the optional arguments are forwarded to the grep utility} \ 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 + { ${kak_opt_grepcmd} "$@" | tr -d '\r' > ${output} 2>&1 & } > /dev/null 2>&1 < /dev/null else - ( ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null + { ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 & } > /dev/null 2>&1 < /dev/null fi printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{ diff --git a/rc/tools/make.kak b/rc/tools/make.kak index fabd7e75..588f6bd2 100644 --- a/rc/tools/make.kak +++ b/rc/tools/make.kak @@ -13,7 +13,7 @@ All the optional arguments are forwarded to the make utility} \ make %{ evaluate-commands %sh{ output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-make.XXXXXXXX)/fifo mkfifo ${output} - ( eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null + { eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 & } > /dev/null 2>&1 < /dev/null printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{ edit! -fifo ${output} -scroll *make* From 9ca9d40c03add0de335cc90e6a055f2972c04b91 Mon Sep 17 00:00:00 2001 From: codesoap Date: Mon, 10 Jun 2019 18:00:11 +0200 Subject: [PATCH 3/4] Revert "Don't create subshells when unnecessary" This reverts commit 6c05e6e0f81243ec503a3de78cf36b5dc798cb1c. Apparently the Linux sh needs subshells here. --- rc/tools/clang.kak | 4 ++-- rc/tools/git.kak | 2 +- rc/tools/grep.kak | 4 ++-- rc/tools/make.kak | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rc/tools/clang.kak b/rc/tools/clang.kak index fc8f5052..e0f90299 100644 --- a/rc/tools/clang.kak +++ b/rc/tools/clang.kak @@ -36,7 +36,7 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are # not hang while clang is running. As completions references a cursor # position and a buffer timestamp, only valid completions should be # displayed. - {{ + {( case ${kak_opt_filetype} in c) ft=c ;; cpp) ft=c++ ;; @@ -100,7 +100,7 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are printf %s\\n "set-option 'buffer=${kak_buffile}' clang_flags ${kak_timestamp} ${flags} set-option 'buffer=${kak_buffile}' clang_errors ${kak_timestamp} ${errors}" | kak -p ${kak_session} - } & } > /dev/null 2>&1 < /dev/null + ) & } > /dev/null 2>&1 < /dev/null } } diff --git a/rc/tools/git.kak b/rc/tools/git.kak index c2434819..47e3d59a 100644 --- a/rc/tools/git.kak +++ b/rc/tools/git.kak @@ -45,7 +45,7 @@ Available commands:\n add\n rm\n blame\n commit\n checkout\n diff\n hide- esac output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-git.XXXXXXXX)/fifo mkfifo ${output} - { git "$@" > ${output} 2>&1 & } > /dev/null 2>&1 < /dev/null + ( git "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null printf %s "evaluate-commands -try-client '$kak_opt_docsclient' %{ edit! -fifo ${output} *git* diff --git a/rc/tools/grep.kak b/rc/tools/grep.kak index 1e105b73..33d5be38 100644 --- a/rc/tools/grep.kak +++ b/rc/tools/grep.kak @@ -11,9 +11,9 @@ All the optional arguments are forwarded to the grep utility} \ 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 + ( ${kak_opt_grepcmd} "$@" | tr -d '\r' > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null else - { ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 & } > /dev/null 2>&1 < /dev/null + ( ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null fi printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{ diff --git a/rc/tools/make.kak b/rc/tools/make.kak index 588f6bd2..fabd7e75 100644 --- a/rc/tools/make.kak +++ b/rc/tools/make.kak @@ -13,7 +13,7 @@ All the optional arguments are forwarded to the make utility} \ make %{ evaluate-commands %sh{ output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-make.XXXXXXXX)/fifo mkfifo ${output} - { eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 & } > /dev/null 2>&1 < /dev/null + ( eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{ edit! -fifo ${output} -scroll *make* From 683c7c1fa53350411922f06fe5f0f27902b51e3e Mon Sep 17 00:00:00 2001 From: codesoap Date: Mon, 10 Jun 2019 18:25:51 +0200 Subject: [PATCH 4/4] Fix fifos for Linux Those were accidentaly broken while fixing for OpenBSD. --- rc/tools/clang.kak | 4 ++-- rc/tools/lint.kak | 4 ++-- rc/tools/python/jedi.kak | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rc/tools/clang.kak b/rc/tools/clang.kak index e0f90299..01ffd0e2 100644 --- a/rc/tools/clang.kak +++ b/rc/tools/clang.kak @@ -36,7 +36,7 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are # not hang while clang is running. As completions references a cursor # position and a buffer timestamp, only valid completions should be # displayed. - {( + (( case ${kak_opt_filetype} in c) ft=c ;; cpp) ft=c++ ;; @@ -100,7 +100,7 @@ The syntaxic errors detected during parsing are shown when auto-diagnostics are printf %s\\n "set-option 'buffer=${kak_buffile}' clang_flags ${kak_timestamp} ${flags} set-option 'buffer=${kak_buffile}' clang_errors ${kak_timestamp} ${errors}" | kak -p ${kak_session} - ) & } > /dev/null 2>&1 < /dev/null + ) & ) > /dev/null 2>&1 < /dev/null } } diff --git a/rc/tools/lint.kak b/rc/tools/lint.kak index d39e7d32..43751907 100644 --- a/rc/tools/lint.kak +++ b/rc/tools/lint.kak @@ -28,7 +28,7 @@ define-command lint -docstring 'Parse the current buffer with a linter' %{ hook -always -once buffer BufCloseFifo .* %{ nop %sh{ rm -r '$dir' } } }" - {{ # do the parsing in the background and when ready send to the session + ({ # do the parsing in the background and when ready send to the session eval "$kak_opt_lintcmd '$dir'/${filename}" | sort -t: -k2,2 -n > "$dir"/stderr @@ -78,7 +78,7 @@ define-command lint -docstring 'Parse the current buffer with a linter' %{ } ' > "$dir"/fifo - } & } >/dev/null 2>&1 /dev/null 2>&1 /dev/null 2>&1 < /dev/null + ) & ) > /dev/null 2>&1 < /dev/null } }