Skip to content

Second command is run when the first one fails #3858

Closed

Description

@peterallin

Describe the Bug

According to the "Coming from Bash" documentation, passing "command1; command2" to nushell should result in running "command1" followed by running "command2" if the first one was successful.
It seems that currently this is only the case if the "nonzero_exit_errors" configuration value is true. The way I understand the documentation, this configuration value should only change whether the failure of the external command is run, and not whether the second command is run.
Apparently the current behavior was introduced in commit 3ae3e3d and probably caused by the fact that an UntaggedValue::nothing() is now sent instead of UntaggedValue::Error, but I am not familiar with the nushell code, so I am not sure about this.

To Reproduce

  1. Make sure that the "nonzero_exit_errors" configuration is set to false
  2. Run the command "false; echo foo"
  3. The string "foo" is printed to the terminal

Expected behavior

I did not expect "foo" to be printed to the terminal

Screenshots

No response

Configuration

0 │ version │ 0.34.0
1 │ build_os │ linux-x86_64
2 │ rust_version │ rustc 1.53.0 (53cb7b09b 2021-06-17)
3 │ rust_channel │ stable-x86_64-unknown-linux-gnu (default)
4 │ cargo_version │ cargo 1.53.0 (4369396ce 2021-04-27)
5 │ pkg_version │ 0.34.0
6 │ build_time │ 2021-07-22 01:30:03
7 │ build_rust_channel │ release
8 │ features │ clipboard-cli, ctrlc, dataframe, default, rustyline, term, trash, uuid, which, zip
9 │ installed_plugins │ binaryview, chart bar, chart line, fetch, from bson, from sqlite, inc, match, post, ps, query json, s3, selector, start, sys, textview, to bson, to sqlite, tree, xpath

Additional Context

No response

Activity

  1. changed the title [-]Second command is run when the frist one fails[/-] [+]Second command is run when the first one fails[/+] on Jul 28, 2021
  2. github-actions commented on Oct 27, 2021

    @github-actions

    This issue is being marked stale because it has been open for 90 days without activity. If you feel that this is in error, please comment below and we will keep it marked as active. Otherwise, it will be closed in 10 days.

  3. added
    category:bug
    and removed on Mar 12, 2022
  4. fdncred commented on Mar 12, 2022

    @fdncred
    Contributor

    still happens in 0.59.1 false; echo foo prints foo

  5. added this to the v0.62.0 milestone on Apr 9, 2022
  6. modified the milestones: v0.62.0, v0.63 on May 3, 2022
  7. flying-sheep commented on May 10, 2022

    @flying-sheep
    Contributor

    Wait, nonzero_exit_errors is not the default? I’m pretty sure I chose nu because it has this sensible behavior.

    /edit: that config doesn’t seem to exist anymore. A sensible script should immediately exit with an error when an external command fails unless it’s wrapped in do -i {} or so.

  8. removed this from the v0.63.0 milestone on May 23, 2022
  9. sholderbach commented on Dec 1, 2022

    @sholderbach
    Member

    I think this should be resolved now. Any specific bugs that might still occur should be addressed in newer issues.

  10. flying-sheep commented on Feb 13, 2023

    @flying-sheep
    Contributor

    OK, so this issue is about

    nu-cmd-throwing-error; echo 'I should not run'
    

    working as expected, and #5347 and #3585 are about external commands?

  11. Alex-EEE commented on Apr 3, 2023

    @Alex-EEE

    Wait, this is insane and incorrect!!!!! In Bash, the second command ALWAYS runs after ;

    If you want the behavior you're describing, then in Bash you use cmd_fails && dont_run

    So basically, this WAS working correctly, and now you guys have broken. Reopen and fix please!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions