Compare commits

..

2 Commits

Author SHA1 Message Date
63e7895905
Let the caller decide how to launch helpers
In the end, we don't need to impose any policy on it,
and it removes a level of quoting, as well as an `eval`.
2020-10-08 19:50:04 +02:00
6aa4bd2ff5
When resuming a child, resume the whole group
SIGTSTP is sent to the entire foreground process group,
so do the some with our SIGCONT.

Debian's default sh (dash) doesn't replace itself with
the command, even if it's the last one in the -c option.

Of course, we do not need to use /bin/sh for the helpers
at all, though it doesn't cost us much.  We could also
issue an explicit `exec`.
2020-10-08 19:49:07 +02:00
2 changed files with 6 additions and 7 deletions

View File

@ -64,7 +64,7 @@ sdn-navigate () {
# helpers after the terminal has been resized while running sdn # helpers after the terminal has been resized while running sdn
command true command true
eval "exec </dev/tty; $helper" || break /bin/sh -c "$helper" </dev/tty || break
done done
# ... possibly zle-line-init # ... possibly zle-line-init
zle reset-prompt zle reset-prompt
@ -86,7 +86,7 @@ function sdn-navigate
test -z "$cd" || cd "$cd" test -z "$cd" || cd "$cd"
test -z "$insert" || commandline --insert "$insert " test -z "$insert" || commandline --insert "$insert "
test -z "$helper" && break test -z "$helper" && break
eval $helper || break /bin/sh -c "$helper" || break
end end
commandline --function repaint commandline --function repaint
end end
@ -111,7 +111,7 @@ sdn-navigate () {
((SDN_P=SDN_P+${#insert}+1)) ((SDN_P=SDN_P+${#insert}+1))
} }
[[ -z "$helper" ]] && break [[ -z "$helper" ]] && break
eval "$helper" || break /bin/sh -c "$helper" || break
done done
} }
sdn-restore () { sdn-restore () {
@ -132,7 +132,7 @@ To start using this navigator, put the following in your 'rc.elv':
use str use str
edit:insert:binding[Alt-o] = { edit:insert:binding[Alt-o] = {
local:reesc = [posix]{ str:replace "'\\''" "''" $posix } local:reesc = [posix]{ str:replace "'\\''" "''" $posix }
local:posix = [cmd]{ eval ($reesc $cmd)" </dev/tty >/dev/tty 2>&1" } local:posix = [cmd]{ /bin/sh -c $cmd </dev/tty >/dev/tty 2>&1 }
# XXX: the -dot is not a stable API, and may hence break soon # XXX: the -dot is not a stable API, and may hence break soon
local:buffer = $edit:current-command local:buffer = $edit:current-command

View File

@ -861,8 +861,7 @@ fun run_program (initializer_list<const char*> list, const string &filename) {
for (auto program : list) for (auto program : list)
if ((found = program)) if ((found = program))
break; break;
g.ext_helper = "/bin/sh -c " + g.ext_helper = found + (" " + shell_escape (filename));
shell_escape (string (found) + " " + shell_escape (filename));
g.quitting = true; g.quitting = true;
return; return;
} }
@ -888,7 +887,7 @@ fun run_program (initializer_list<const char*> list, const string &filename) {
// We don't provide job control--don't let us hang after ^Z // We don't provide job control--don't let us hang after ^Z
while (waitpid (child, &status, WUNTRACED) > -1 && WIFSTOPPED (status)) while (waitpid (child, &status, WUNTRACED) > -1 && WIFSTOPPED (status))
if (WSTOPSIG (status) == SIGTSTP) if (WSTOPSIG (status) == SIGTSTP)
kill (child, SIGCONT); kill (-child, SIGCONT);
tcsetpgrp (STDOUT_FILENO, getpgid (0)); tcsetpgrp (STDOUT_FILENO, getpgid (0));
if (WIFEXITED (status) && WEXITSTATUS (status)) { if (WIFEXITED (status) && WEXITSTATUS (status)) {