Fine, I guess you want an argument list.
\n$ [\"test -d /mnt/D/DCIM\", \"test -r /mnt/D/DCIM\"] | each {run-external ($in | split row ' ')}\nError: nu::shell::eval_block_with_input\n\n × Eval block failed with pipeline input\n ╭─[entry #142:1:2]\n 1 │ [\"test -d /mnt/D/DCIM\", \"test -r /mnt/D/DCIM\"] | each {run-external ($in | split row ' ')}\n · ──────────┬──────────\n · ╰── source value\n ╰────\n\nError: nu::shell::cant_convert\n\n × Can't convert to string.\n ╭─[entry #142:1:69]\n 1 │ [\"test -d /mnt/D/DCIM\", \"test -r /mnt/D/DCIM\"] | each {run-external ($in | split row ' ')}\n · ──────────┬──────────\n · ╰── can't convert list<string> to stringThis one through me through a loop, but I figured out it meant that run-external can't accept it as a list of strings. Annoying, but fine, quirk of the language.
$ [\"test -d /mnt/D/DCIM\", \"test -r /mnt/D/DCIM\"] | each {run-external ...($in | split row ' ')}\nError: nu::parser::missing_positional\n\n × Missing required positional argument.\n ╭─[entry #141:1:69]\n 1 │ [\"test -d /mnt/D/DCIM\", \"test -r /mnt/D/DCIM\"] | each {run-external ...($in | split row ' ')}\n · ▲\n · ╰── missing commandFuck. Fine, I'll use a different approach.
\n$ [\"test -d /mnt/D/DCIM\", \"test -r /mnt/D/DCIM\"] | split column ' ' | each {run-external ...$in}\nError: nu::parser::missing_positional\n\n × Missing required positional argument.\n ╭─[entry #145:1:88]\n 1 │ [\"test -d /mnt/D/DCIM\", \"test -r /mnt/D/DCIM\"] | split column ' ' | each {run-external ...$in}\n · ▲\n · ╰── missing command\n ╰────\n help: Usage: run-external <command> ...(args) . Use `--help` for more information.Are you serious? Okay, I guess it REALLY needs to be sure that it's not the one accepting a zero length list of arguments. quirk_of_the_language.jpeg
\n$ [\"test -d /mnt/D/DCIM\", \"test -r /mnt/D/DCIM\"] | split column ' ' | each {run-external $in.column1 ...($in | values | skip 1 )}\n╭───┬──╮\n│ 0 │ │\n│ 1 │ │\n╰───┴──╯Finally! But oh god damnit, it won't let me use complete or access details of the command's output. I tried looking into the do command, but it doesn't let me 'ignore errors' while capturing their existence. I want to know about the errors, but I don't want them to propagate to my script.
Side note: This is a quite convoluted way to achieve run-external's argument requirements. Is this really the way?
Testing several directories with test (assuming test from coreutils) would look like this:
# `src` and `assets` are two directories that exist in the folder I tested this in\n[src assets] | each { test -r $in -a -d $in | complete | get exit_code } | all { $in == 0 }\n# outputs `true`\n\nMy approach was this: Take multiple commands in strings
\n
It goes against one of nushell's design principles: there's no eval in Nushell. No wonder it was hard to work it around.
-
|
I'm trying out Nushell and this stuff has genuinely got me tweaking, wondering if this language is just insanely unintuitive or if I'm not reading properly. I'm trying to test that several directories exist, as well as that I can READ them. Unfortunately, While trying to solve this, I got stuck. My approach was this:
Note: It is very likely I am not following best Nu practices and am posting a XY problem - if you want to suggest an alternative method (such as parsing Here is the rabbit hole of development I underwent: $ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | each {run-external $in}
Error: nu::shell::eval_block_with_input
× Eval block failed with pipeline input
╭─[entry #143:1:2]
1 │ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | each {run-external $in}
· ──────────┬──────────
· ╰── source value
╰────
Error: nu::shell::external_command
× External command failed
╭─[entry #143:1:56]
1 │ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | each {run-external $in}
· ──────┬─────
· ╰── Command `test -d /mnt/D/DCIM` not found
╰────
help: `test -d /mnt/D/DCIM` is neither a Nushell built-in or a known external commandFine, I guess you want an argument list. $ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | each {run-external ($in | split row ' ')}
Error: nu::shell::eval_block_with_input
× Eval block failed with pipeline input
╭─[entry #142:1:2]
1 │ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | each {run-external ($in | split row ' ')}
· ──────────┬──────────
· ╰── source value
╰────
Error: nu::shell::cant_convert
× Can't convert to string.
╭─[entry #142:1:69]
1 │ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | each {run-external ($in | split row ' ')}
· ──────────┬──────────
· ╰── can't convert list<string> to stringThis one through me through a loop, but I figured out it meant that $ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | each {run-external ...($in | split row ' ')}
Error: nu::parser::missing_positional
× Missing required positional argument.
╭─[entry #141:1:69]
1 │ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | each {run-external ...($in | split row ' ')}
· ▲
· ╰── missing commandFuck. Fine, I'll use a different approach. $ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | split column ' ' | each {run-external ...$in}
Error: nu::parser::missing_positional
× Missing required positional argument.
╭─[entry #145:1:88]
1 │ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | split column ' ' | each {run-external ...$in}
· ▲
· ╰── missing command
╰────
help: Usage: run-external <command> ...(args) . Use `--help` for more information.Are you serious? Okay, I guess it REALLY needs to be sure that it's not the one accepting a zero length list of arguments. quirk_of_the_language.jpeg $ ["test -d /mnt/D/DCIM", "test -r /mnt/D/DCIM"] | split column ' ' | each {run-external $in.column1 ...($in | values | skip 1 )}
╭───┬──╮
│ 0 │ │
│ 1 │ │
╰───┴──╯Finally! But oh god damnit, it won't let me use Side note: This is a quite convoluted way to achieve |
Beta Was this translation helpful? Give feedback.
-
|
Testing several directories with # `src` and `assets` are two directories that exist in the folder I tested this in
[src assets] | each { test -r $in -a -d $in | complete | get exit_code } | all { $in == 0 }
# outputs `true`
It goes against one of nushell's design principles: there's no |
Beta Was this translation helpful? Give feedback.
Testing several directories with
test(assumingtestfromcoreutils) would look like this:It goes against one of nushell's design principles: there's no
evalin Nushell. No wonder it was hard to work it around.