Skip to content

multiple elifs will fail #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JoePelz opened this issue Nov 17, 2015 · 1 comment
Open

multiple elifs will fail #19

JoePelz opened this issue Nov 17, 2015 · 1 comment
Labels

Comments

@JoePelz
Copy link
Contributor

JoePelz commented Nov 17, 2015

The issue is with multiple elif statements, if a previous statement has already run.
The following will generate erroneous output:

x = 1
y = 1
x == 1 && y == 1 if
  echo "x=1 y=1, "
? elif x == 1
  echo "x=1 y!=1, "
? elif y == 1
  echo "x!=1 y=1, "
? else
  echo "x!=1 y!=1, "

It will print x=1 y=1, x!=1, y=1 rather than the expected x=1 y=1,
No workaround right now.

The fix may be to apply DeMorgan's Law on the second or later elif when negating the previous condition.

@JoePelz JoePelz added the bug label Nov 17, 2015
@JoePelz
Copy link
Contributor Author

JoePelz commented Nov 20, 2015

Workaround right now is discrete if statements

x == 1 && y == 1 if
  echo "x=1 y=1, "
y!=1 && x==1 if
  echo "x=1 y!=1, "
y==1 && x!=1 if
  echo "x!=1 y=1, "
x!=1 && y!=1 else
  echo "x!=1 y!=1, "

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant