Skip to content
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

Fix syntax for "[" command #25

Merged
merged 1 commit into from
Feb 11, 2017
Merged

Fix syntax for "[" command #25

merged 1 commit into from
Feb 11, 2017

Conversation

wtanaka
Copy link
Contributor

@wtanaka wtanaka commented Feb 5, 2017

== is a bash-ism

dash:

$ if [ "a" == "b" ]; then echo true; else echo false; fi
dash: 1: [: a: unexpected operator
false
$ if [ "a" == "a" ]; then echo true; else echo false; fi
dash: 2: [: a: unexpected operator
false
$ if [ "a" = "b" ]; then echo true; else echo false; fi
false
$ if [ "a" = "a" ]; then echo true; else echo false; fi
true

bash:

$ if [ "a" == "b" ]; then echo true; else echo false; fi
false
$ if [ "a" == "a" ]; then echo true; else echo false; fi
true
$ if [ "a" = "b" ]; then echo true; else echo false; fi
false
$ if [ "a" = "a" ]; then echo true; else echo false; fi
true

zsh:

% if [ "a" == "b" ]; then echo true; else echo false; fi
zsh: = not found
% if [ "a" == "a" ]; then echo true; else echo false; fi
zsh: = not found
% if [ "a" = "b" ]; then echo true; else echo false; fi
false
% if [ "a" = "a" ]; then echo true; else echo false; fi
true

== is a bash-ism

dash:
```
$ if [ "a" == "b" ]; then echo true; else echo false; fi
dash: 1: [: a: unexpected operator
false
$ if [ "a" == "a" ]; then echo true; else echo false; fi
dash: 2: [: a: unexpected operator
false
$ if [ "a" = "b" ]; then echo true; else echo false; fi
false
$ if [ "a" = "a" ]; then echo true; else echo false; fi
true
```

bash:
```
$ if [ "a" == "b" ]; then echo true; else echo false; fi
false
$ if [ "a" == "a" ]; then echo true; else echo false; fi
true
$ if [ "a" = "b" ]; then echo true; else echo false; fi
false
$ if [ "a" = "a" ]; then echo true; else echo false; fi
true
```

zsh:
```
% if [ "a" == "b" ]; then echo true; else echo false; fi
zsh: = not found
% if [ "a" == "a" ]; then echo true; else echo false; fi
zsh: = not found
% if [ "a" = "b" ]; then echo true; else echo false; fi
false
% if [ "a" = "a" ]; then echo true; else echo false; fi
true
````
@wtanaka
Copy link
Contributor Author

wtanaka commented Feb 5, 2017

@neillturner thanks for #23 (comment) !

I still think the shell syntax is incorrect though -- I pasted some small test cases to this pull request description to illustrate.

@neillturner
Copy link
Owner

ok. i mostly consider bash. but i will test this and as long as it works merge and release

@neillturner neillturner merged commit 3731da1 into neillturner:master Feb 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants