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
Not sure if this is a bug of a lack of feature ... Let's consider the which command, for example. Its signature is
which {flags} <application> ...(rest)
Basically, it wants at least one application name to look up, but could have more. So, why I can't do this:
[ notepad cmd powershell ] | which ...$in
Error: nu::parser::missing_positional
× Missing required positional argument.
╭─[entry #10:1:36]
1 │ [ notepad cmd powershell ] | which ...$in
· ▲
· ╰── missing application
╰────
help: Usage: which {flags} <application> ...(rest) . Use `--help` for more information.
Describe the solution you'd like
It would be great if the following:
[ notepad cmd powershell ] | which ...$in
would be allowed, with the result as in the alternatives below.
The ...$in part would be split into elements
The first items would be used for explicit parameters, as per function
If the first items don't satisfy the explicit parameters (not enough, wrong type, etc...), runtime error would be thrown
Only what is left would be used for the ...(rest) part
Describe alternatives you've considered
There are workarounds, for example:
[ notepad cmd powershell ] | each { which $in } | flatten
# below is what I'd like nushell to do automatically
[ notepad cmd powershell ] | which $in.0...($in| skip 1)
But they are quite verbose...
Another approach is to change the signature of which, leaving only the ...(rest) part. But that would be a solution for one command only.
I'm not sure if you're asking specifically about which or other commands too. This is something that needs to be done on a per-command basis. We can't allow [foo bar baz] | f ...$in if f has signature def f [ a: int, ...b: string ] or something. That would let you bypass Nushell's static analysis.
If you're only asking about which, I think all that needs to be done here is changing the signature of which to only take rest arguments, rather than taking a single application followed by rest arguments. That mostly just means removing this bit:
There are definitely other commands with this issue, I'm not sure if we've tackled them all yet so I think we should leave this open until we've hit them all. I have a list in a drawing board thread called "restification" or something like that
There are definitely other commands with this issue, I'm not sure if we've tackled them all yet so I think we should leave this open until we've hit them all. I have a list in a drawing board thread called "restification" or something like that
If you know any more know commands with this issue I can work on that.
help commands|where ((($it.params|length) >1) and
($it.params.1.namestarts-with"...") and
($it.params.0.type==$it.params.1.type) and
($it.params.0.required))
Excluding split column which is a false positive, that leaves us with:
drop nth
get
sleep
get is somewhat complicated because I believe it has different code paths for single selectors versus multiple selectors, but I think the other ones should be doable. They seem notably less useful than some of the previous ones we've changed like this but it's good to be consistent I suppose
help commands
| where ((($it.params | length) > 1) and
($it.params.1.name starts-with "...") and
($it.params.0.type == $it.params.1.type) and
($it.params.0.required))
Excluding split column which is a false positive, that leaves us with:
drop nth
get
sleep
get is somewhat complicated because I believe it has different code paths for single selectors versus multiple selectors, but I think the other ones should be doable. They seem notably less useful than some of the previous ones we've changed like this but it's good to be consistent I suppose
I think for sleep it is not really sensible to spread. The support for multiple durations through the rest parameters there is to fake complex duration literals: sleep 1hr 30min 24sec which is a courtesy to manual entry but not replicated in other places that I am aware of and not really the recommended way to express that programmatically (it would be a single duration value expressing that)
collect all rows to drop from both integers and ranges into one combined list.
if you just mean collecting the indices into a list that should be fine (although you would have to do something fancy to express unbounded ranges), but we definitely don't want to collect the actual input since drop nth is a streaming command
Thanks for the clarification! Yes, I meant collecting only the indices from both integers and ranges into a list—not the actual input. The input itself remains streamed. I will try if If I am able to achieve this.
@132ikl since drop now supports spread I was thinking to work on the get. Can you guide me as per what we are expecting the get command to look like after supporting the spread?
Implemented in #18220 - wires the spread case through the parser and get's rest-arg handling with tests for single-spread, mixed, and empty-spread cases.
Activity
ysthakur commentedon May 23, 2025
I'm not sure if you're asking specifically about
whichor other commands too. This is something that needs to be done on a per-command basis. We can't allow[foo bar baz] | f ...$iniffhas signaturedef f [ a: int, ...b: string ]or something. That would let you bypass Nushell's static analysis.If you're only asking about
which, I think all that needs to be done here is changing the signature ofwhichto only take rest arguments, rather than taking a single application followed by rest arguments. That mostly just means removing this bit:nushell/crates/nu-command/src/system/which_.rs
Line 17 in 88d421d
At runtime,
whichalready handles receiving an empty list of applications:nushell/crates/nu-command/src/system/which_.rs
Lines 194 to 204 in 88d421d
132ikl commentedon Jun 2, 2025
There are definitely other commands with this issue, I'm not sure if we've tackled them all yet so I think we should leave this open until we've hit them all. I have a list in a drawing board thread called "restification" or something like that
fix(which): remove required positional argument to allow spread input (…
kumarUjjawal commentedon Jun 3, 2025
If you know any more know commands with this issue I can work on that.
132ikl commentedon Jun 3, 2025
this command should list all commands like this:
Excluding
split columnwhich is a false positive, that leaves us with:drop nthgetsleepgetis somewhat complicated because I believe it has different code paths for single selectors versus multiple selectors, but I think the other ones should be doable. They seem notably less useful than some of the previous ones we've changed like this but it's good to be consistent I supposekumarUjjawal commentedon Jun 3, 2025
I will take a look at this.
sholderbach commentedon Jun 3, 2025
I think for
sleepit is not really sensible to spread. The support for multiple durations through the rest parameters there is to fake complex duration literals:sleep 1hr 30min 24secwhich is a courtesy to manual entry but not replicated in other places that I am aware of and not really the recommended way to express that programmatically (it would be a single duration value expressing that)kumarUjjawal commentedon Jun 4, 2025
I was thinking going in this direction for
drop nthan integer (e.g., drop nth 0 2)
an integer range (e.g., drop nth 3..5)
collect all rows to drop from both integers and ranges into one combined list.
Supports mixed args, like:
drop nth 0 2 4..5 7.. # drops 0, 2, 4, 5, 7 and onward
Automatically sorts and deduplicates the list of row indices to drop.
reject:
i) Negative numbers
ii) Decreasing ranges like 5..2
iii) Float ranges
132ikl commentedon Jun 4, 2025
sounds good, except for:
if you just mean collecting the indices into a list that should be fine (although you would have to do something fancy to express unbounded ranges), but we definitely don't want to collect the actual input since
drop nthis a streaming commandkumarUjjawal commentedon Jun 5, 2025
Thanks for the clarification! Yes, I meant collecting only the indices from both integers and ranges into a list—not the actual input. The input itself remains streamed. I will try if If I am able to achieve this.
kumarUjjawal commentedon Jun 5, 2025
@132ikl Does this look good?
132ikl commentedon Jun 5, 2025
yes, looks good!
kumarUjjawal commentedon Jul 3, 2025
@132ikl since drop now supports spread I was thinking to work on the
get. Can you guide me as per what we are expecting thegetcommand to look like after supporting the spread?A-Lamia commentedon Jul 13, 2025
idk if this is the same issue but with pacman, yay, paru this fails
["ouch" "nushell" "jq"] | paru -S ...$inThe command will execute correctly but it will terminate before you can interact with it.
EDIT: just for some added context i came across this issue by trying to install a list of packages from a file, sorry if this is not the same issue.
mvanhorn commentedon May 16, 2026
Implemented in #18220 - wires the spread case through the parser and
get's rest-arg handling with tests for single-spread, mixed, and empty-spread cases.feat: enable spread operator for get command rest args (#18220)