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
non-strings are not piped to external commands #14452
A:error-silent-failCases where nothing or something bad happens and an error would be helpful and expectedA:external-commandsIssues related to external commandsA:redirection-pipeAll related to redirection to files or more complex pipelines with STDERRA:type-systemProblems or features related to nushell's type system
If a function returns a value that is not a string (like int, float, bool etc) it should be implicitly converted into string when fed to an external command
We already implicitly convert for arguments to external commands, so I don't see why we can't for the piped input as well. As long as the conversion is consistent and documented, I think that would be a little more ergonomic (e.g., #14090).
Alternatively, we could remove the implicit conversion for arguments if we want stricter typing. Either way, the two should match.
I'm thinking we should explicitly list pipeline input types for run-external (unfortunately, this will be a shell error instead of a parse error until we fix the conditionally discarded pipeline input problem) only convert primitives with an obvious conversion.
I agree with @IanManske on the point of argument conversions matching pipeline input conversions. I think we should only convert primitives which have an obvious conversion, but not things like dates, lists, records, etc. I think a decent heuristic is that the string representation is the same as the literal typed into the REPL then we implicitly convert, otherwise we don't.
I might take a crack at this soon if I get the chance.
A:error-silent-failCases where nothing or something bad happens and an error would be helpful and expectedA:external-commandsIssues related to external commandsA:redirection-pipeAll related to redirection to files or more complex pipelines with STDERRA:type-systemProblems or features related to nushell's type system
Activity
fdncred commentedon Nov 27, 2024
why? what's the use case for this?
sholderbach commentedon Nov 27, 2024
I don't think we should implicitly coerce but it should raise a mismatch if its not string or binary data going to an external.
ineu commentedon Nov 28, 2024
I originally faced this bug while creating a script to manage screen brightness. The logic to increase the brightness is:
So my code was:
and it took me some time to realize why
sudo teecreates an empty file.That's a great option. Much better than silently ignoring the output.
IanManske commentedon Nov 28, 2024
We already implicitly convert for arguments to external commands, so I don't see why we can't for the piped input as well. As long as the conversion is consistent and documented, I think that would be a little more ergonomic (e.g., #14090).
Alternatively, we could remove the implicit conversion for arguments if we want stricter typing. Either way, the two should match.
132ikl commentedon Feb 28, 2025
Related: #14452
132ikl commentedon Feb 28, 2025
I'm thinking we should explicitly list pipeline input types for
run-external(unfortunately, this will be a shell error instead of a parse error until we fix the conditionally discarded pipeline input problem) only convert primitives with an obvious conversion.I agree with @IanManske on the point of argument conversions matching pipeline input conversions. I think we should only convert primitives which have an obvious conversion, but not things like dates, lists, records, etc. I think a decent heuristic is that the string representation is the same as the literal typed into the REPL then we implicitly convert, otherwise we don't.
I might take a crack at this soon if I get the chance.
kronberger-droid commentedon Nov 14, 2026
Still reproduces on 0.117:
123 | ^catprints nothing.#16916 is the same problem.
echocommand fails to pipe int to external command #16916 as a duplicate of this issue