Skip to content

It doesn't supports "&&" #4139

Closed
Closed

Description

@danimesq

Describe the bug

When typing clear && git status, it outputs:

error: clear unexpected &&
┌─ shell:2:7
│
2 │ clear && git status
│ ^^ unexpected argument (try clear -h)

How to reproduce

Just run clear && git status or any other commands using &&

Expected behavior

Should work normally as it did in bash.

Screenshots

Screenshot from 2021-11-20 23-04-48

Configuration

┌─ shell:1:1
│
1 │ > version | pivot key value | to md
│ ^ command > not found

Additional context

Activity

  1. sophiajt commented on Nov 22, 2021

    @sophiajt
    Contributor

    in nushell, we use && for conditions like if $x < 10 && $y < 13. For the bash style &&, you can use ;

  2. danimesq commented on Nov 22, 2021

    @danimesq
    ContributorAuthor

    For the bash style &&, you can use ;

    Here's another issue:
    When using ; inside quotes, like in a git commit message:
    Screenshot from 2021-11-20 21-26-00

  3. sophiajt commented on Nov 22, 2021

    @sophiajt
    Contributor

    @danimesq - can you file that one as a separate issue?

  4. danimesq commented on Nov 22, 2021

    @danimesq
    ContributorAuthor

    in nushell, we use && for conditions like if $x < 10 && $y < 13

    And how to switch && for ; while not getting rid of nushell, so it can work usually without scaring away bash users?

    can you file that one as a separate issue?

    OK

  5. sophiajt commented on Nov 22, 2021

    @sophiajt
    Contributor

    @danimesq unfortunately, if we tried to follow bash, we'd have a worse syntax (neither && nor < would work in the example above)

  6. danimesq commented on Nov 22, 2021

    @danimesq
    ContributorAuthor

    Can bash scripts loaded in nushell still work using &&?

  7. sophiajt commented on Nov 22, 2021

    @sophiajt
    Contributor

    yes, for bash scripts, we'll call out to bash. For your example, when you call out to the external command you may need to put \ in front of the semicolon.

    We should fix that issue, but the \ should help you workaround it for now

  8. kubouch commented on Nov 30, 2021

    @kubouch
    Contributor

    I'll close this since we don't plan adding a support for Bash-like &&.

  9. danimesq commented on Nov 30, 2021

    @danimesq
    ContributorAuthor

    Here's another issue:
    When using ; inside quotes, like in a git commit massage:

    Done and merged here: #4157.

  10. avkonst commented on Sep 30, 2022

    @avkonst

    If ; is nu's "operator" for bash's &&, what is nu's "operator" for bash's || ?

  11. jondlm commented on Apr 30, 2026

    @jondlm

    If ; is nu's "operator" for bash's &&, what is nu's "operator" for bash's || ?

    https://www.nushell.sh/commands/docs/try.html

  12. nightscape commented on Oct 13, 2026

    @nightscape
    Contributor

    I constantly run into issues with this. Many tools assume they can call commands like $SHELL 'command_a && command_b' (not sure about the exact syntax, but something to that effect).
    If NuShell doesn't allow this, every other tool in the world needs to adapt to NuShell, which just won't happen for a long time.
    I love NuShell, but this single issue is annoying as hell.

    Wouldn't it be possible to treat command_a like an expression with exit code 0 evaluating to true and everything else evaluating to false?

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions