You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Programs spawned with 'exec' pass arguments to exec instead of the program #2675
Describe the bug
In some cases, the exec command (which seems to be evoked internally) does not recognize arguments passed to the spawned program. Apparently, it thinks the arguments belong to exec and throws an error.
To Reproduce Reproducible ONLY when nushell is a default login shell. When nu is launched from other default shell (e.g., bash) the issue does not appear.
I encountered this issue specifically under two circumstances:
Using customized ssh commands from ~/.ssh/config
Passing arguments to gdb --args
Steps to reproduce the behavior:
Set nushell as the default login shell, log out and log back in.
Put a ProxyCommand config into ~/.ssh/config, for example:
OK so closing nu after exec is intended. This issue still persists though. I'm pretty sure it's just nushell passing the arguments to exec instead of the spawned process.
changed the title [-]exec sometimes fails when running programs with arguments[/-][+]Programs spawned with 'exec' pass arguments to exec instead of the program[/+]on Oct 31, 2020
Doesn't seem to work with gdb, though -- maybe it internally stripts the quotes or something like that.
The core of the problem is that the programs spawn the commands with exec, assuming that every shell == POSIX shell. For example, when you run ssh ServerUseX, ssh spawns the following:
but then it finds nushell's exec which tries to interpret -XC as its flag.
I think the best solution would be to add an option to tell the parser: "Just give me all args as strings and don't bother parsing them". I'm not sure yet whether it would be doable just by implementing a new SyntaxShape or by hard-coding it into the parser, I haven't looked at the parser code yet. @jonathandturner, what do you think about this? Perhaps I could take this as my first leap into the nushell's internals.
Might be related, I wasn't even aware that nushell supports escapes. I tried escapes with the gdb command but it made some random output -- so the issue you linked might be related to that.
I see the quotes as a workaround, though. Imagine if you don't have the option to modify the ssh proxy command, then you'd be screwed. I was thinking nushell could adopt some very very limited subset of POSIX behavior that some applications depend on, like exec in this case, to make life easier in certain specialized cases.
Seems like people are stumbling on the "exec" issue from time to time. It works with the workaround wrapping the flag in quotes but sometimes this is not an option when using some 3rd party tool.
Seems like people are stumbling on the "exec" issue from time to time. It works with the workaround wrapping the flag in quotes but sometimes this is not an option when using some 3rd party tool.
Particularly, there doesn't seem to be any way of getting gdb --args to call exec in a way that nushell is happy with, which is somewhat of a pain :)
@RAOF I managed to work around gdb by setting the SHELL environment variable to bash. In Nushell, you can do this, for example: with-env { SHELL: /bin/bash } { gdb --args program args... }
Reacted by Christopher James Halse Rogers and Matias Barletta
Activity
kubouch commentedon Oct 16, 2020
When I type
exec lsorexec 'ps aux'(as in the exec --help message), the nu exits. I'm not sure if that is intentional.fdncred commentedon Oct 16, 2020
@kubouch I asked that question of @thegedge a while back. See it here in the PR.
kubouch commentedon Oct 16, 2020
OK so closing nu after exec is intended. This issue still persists though. I'm pretty sure it's just nushell passing the arguments to exec instead of the spawned process.
[-]exec sometimes fails when running programs with arguments[/-][+]Programs spawned with 'exec' pass arguments to exec instead of the program[/+]jakevossen5 commentedon Mar 8, 2021
I can confirm that this is also an issue on macOS 11.2.2
kubouch commentedon May 1, 2021
OK, I looked into this and a partial solution is to wrap flag-like arguments into quotes, like this (excerpt from
~/.ssh/config):Host ServerUseX ProxyCommand ssh '-XC' [email protected]instead of
Host ServerUseX ProxyCommand ssh -XC [email protected]Doesn't seem to work with gdb, though -- maybe it internally stripts the quotes or something like that.
The core of the problem is that the programs spawn the commands with
exec, assuming that every shell == POSIX shell. For example, when you runssh ServerUseX, ssh spawns the following:but then it finds nushell's
execwhich tries to interpret-XCas its flag.I think the best solution would be to add an option to tell the parser: "Just give me all args as strings and don't bother parsing them". I'm not sure yet whether it would be doable just by implementing a new SyntaxShape or by hard-coding it into the parser, I haven't looked at the parser code yet. @jonathandturner, what do you think about this? Perhaps I could take this as my first leap into the nushell's internals.
fdncred commentedon May 1, 2021
I noticed some weird quote handling with external the other day too related to #3363. I wonder if these things are related.
nushell/crates/nu-command/src/commands/classified/external.rs
Lines 104 to 122 in a8f5558
kubouch commentedon May 1, 2021
Might be related, I wasn't even aware that nushell supports escapes. I tried escapes with the gdb command but it made some random output -- so the issue you linked might be related to that.
I see the quotes as a workaround, though. Imagine if you don't have the option to modify the ssh proxy command, then you'd be screwed. I was thinking nushell could adopt some very very limited subset of POSIX behavior that some applications depend on, like exec in this case, to make life easier in certain specialized cases.
fdncred commentedon May 1, 2021
Nushell doesn't support escapes but since these are external commands, external commands support escapes, typically. That's my rationale.
github-actions commentedon Jun 24, 2021
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
kubouch commentedon Jun 24, 2021
I don't have the issue on 0.33 anymore so I'll close it and we can reopen if somebody runs into it again.
kubouch commentedon Sep 15, 2021
Seems like people are stumbling on the "exec" issue from time to time. It works with the workaround wrapping the flag in quotes but sometimes this is not an option when using some 3rd party tool.
kubouch commentedon Oct 27, 2021
Similar issues: #3703 #4005
RAOF commentedon May 18, 2022
Particularly, there doesn't seem to be any way of getting
gdb --argsto callexecin a way that nushell is happy with, which is somewhat of a pain :)kubouch commentedon May 18, 2022
@RAOF I managed to work around gdb by setting the
SHELLenvironment variable to bash. In Nushell, you can do this, for example:with-env { SHELL: /bin/bash } { gdb --args program args... }dzintars commentedon Nov 21, 2022
Encountered this as well.
Solved via:
Ideally i would like to avoid
ProxyCommandand use defaultProxyJumpbecause it little bit complicates SSH config auto-generation in the pipelines.fdncred commentedon Dec 22, 2022
closing as fixed by #7527. please re-open if it's not fixed.