Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mixing the && and || operators with "and"/"or" does not behave #6089

@Phidica

Description

@Phidica

Tried using tagged release fish 3.0.2 as well as current master, built from source on Fedora 29, running in Gnome Terminal.

Problem

The command true && and true sets the exit code to 1 but is otherwise not indicated to be misbehaving.

Changing the command to true && and echo word reveals that the final statement is never executed (nothing is printed). Running true && and exits with code 2 instead and prints the help information for and. Running true && or exits with code 2 and prints the help info for or.

Similar results are observed with ||. false || and and false || or exit with code 2 and print the help info for and or or.

In all these cases, a command placed after the and or or is never executed.

Expected behaviour

I think that these two constructs shouldn't be allowed to be mixed in this way, as the results are unintuitive. The parser should expressly reject and or or when they follow && or ||, to prevent users accidentally creating structures that don't behave as they may anticipate, with commands that never execute.

Metadata

Metadata

Labels

bugSomething that's not working as intended

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions