change display_error.exit_code to false#13873
Conversation
|
I think the better option is to change the rust code to be exit_code = false so it silences more errors. |
|
Actually I don't quite sure, it seems to me that @IanManske want to make it more explicit |
|
People disliked the extra error messages, so actually I think it should be false everywhere. |
|
@IanManske I get why you default to I'm just not sure they realize where it will be useful yet. It may be that what we are seeing right now is just backlash against the verbose messages in the REPL, which is caused by having existing |
|
i'm fine with either way, thanks @WindSoilder 🙏 |
|
This is an example of true and false. with true❯ $env.config.display_errors.exit_code = true
❯ let status = try {
❯❯❯ git status
❯❯❯ } catch {|e| print -n ""}
fatal: not a git repository (or any of the parent directories): .git
Error: nu::shell::non_zero_exit_code
× External command had a non-zero exit code
╭─[entry #25:2:3]
1 │ let status = try {
2 │ git status
· ─────┬────
· ╰── exited with code 128
3 │ } catch {|e| print -n ""}
╰────
❯ $env.LAST_EXIT_CODE
128with false❯ $env.config.display_errors.exit_code = false
❯ let status = try {
❯❯❯ git status
❯❯❯ } catch {|e| print -n ""}
fatal: not a git repository (or any of the parent directories): .git
❯ $env.LAST_EXIT_CODE
128my vote is for false everywhere |
|
@fdncred Isn't the fact that As for the defaults, the example you give is already the default today. The only reason you are seeing the expanded errors in the REPL is because you have an outdated config. Don't you want to see the line number the error occurred on when running it in a script? nu script.nu
Error: nu::shell::non_zero_exit_code
× External command had a non-zero exit code
╭─[/home/ntd/testing/script.nu:90:2]
89 │ print -n ""
90 │ ^which foobaz
· ──┬──
· ╰── exited with code 1
91 │
╰────If it's We can also change the "with config" default for all users if we implement #13671. That gives us the best of both worlds:
|
probably
correct. i was just linking to where the code was that needed to be changed.
only when i set it to true, so it's opt-in |
|
do you think we can get this into shape before the release? |
You would have to set it to If it's possible to make scripts and REPL w/o config have different default behavior, that would be perfect, but I'm not sure if it's feasible. It looks like @IanManske alluded to doing so in #13515, maybe he has some insight. |
|
Yep @132ikl, that's exactly what I was thinking 😉. After, #13802, a config env var with all fields initialized is present at launch without a config file loaded1. It should be easy after this, to change a few default values in the config based on whether nushell was launched as a REPL or a script. IMO this solution is the best of both worlds. Footnotes
|
# Description This is a follow up for pr: #13873 In that pr, I left 2 TODOs about tests, this pr is going to resolve them. # User-Facing Changes NaN # Tests + Formatting Added 2 tests
The idea comes from @amtoine, I think it would be good to keey
display_error.exit_codesame value, if user is using default config or using no config file at all.