Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of sh -i in desk run causes process suspension in pipelines #86

Open
groner opened this issue Apr 16, 2019 · 2 comments
Open

Use of sh -i in desk run causes process suspension in pipelines #86

groner opened this issue Apr 16, 2019 · 2 comments

Comments

@groner
Copy link
Contributor

groner commented Apr 16, 2019

This makes desk unusable in some pipelines (or any pipelines if you don't like guessing).

This is a little complicated to reproduce. For instance, changing the first command from ls to seq 10 usually succeeds. I'm not sure what the reason is here, but it is likely related to the fact that seq can produce output sooner than ls.

:; desk run hello ls | desk run hello tac
[hangs]^C
[1]+  Stopped                 desk run hello ls | desk run hello tac
:; fg
desk run hello ls | desk run hello tac
[exits]

Or, if run with no controlling tty, we get warnings but the pipeline is otherwise functional.

:; desk run hello ls | desk run hello tac
bash: cannot set terminal process group (6214): Inappropriate ioctl for device
bash: no job control in this shell
bash: cannot set terminal process group (6211): Inappropriate ioctl for device
bash: no job control in this shell
[correct output follows]

I think this all has something to do with multiple shells trying to manage the foreground process on the terminal. This can be avoided if desk run stops using the -i flag and simply injects . $DESK_ENV; in front of the command to run.

@groner
Copy link
Contributor Author

groner commented Apr 17, 2019

The following patch addresses this, but it breaks the alias test.

--- desk
+++ desk
@@ -141,9 +141,9 @@ cmd_go() {
 cmd_run() {
     local TODESK="$1"
     shift;
     if [ $# -eq 1 ]; then
-        cmd_go "$TODESK" -ic "$1"
+        cmd_go "$TODESK" -c ". \$DESK_ENV; $1"
     else
-        cmd_go "$TODESK" -ic '"$@"' -- "$@"
+        cmd_go "$TODESK" -c '. $DESK_ENV; "$@"' -- "$@"
     fi
 }

@groner
Copy link
Contributor Author

groner commented Apr 17, 2019

One way to make aliases work would be to use the load code in #80, and couple it with a shell function that handles run in a subshell (using parens, not $SHELL -c).

I guess this could still probably break somebody's workflow somewhere. Not hard to fix, but maybe not fun to trip over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant