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

Add more comprehensive support for compare operators #70

Merged
merged 6 commits into from
Nov 7, 2023

Conversation

monstermichl
Copy link
Contributor

@monstermichl monstermichl commented Nov 7, 2023

I tried to use the converter but ran into problems with if-compare-operators, so I extended it. Additionally, I removed the first space after the command expansion because the leading space can lead to problems in further comparisons.

Before accepting the pull-request, please make sure that everything works as expected. Even though I added tests that passed and checked the correct functionality with the following script, you might have some additional tests to make sure, this changes don't break anything.

if [ 1 == 1 ]; then echo 1; fi
if [ 1 != 2 ]; then echo 2; fi
if [ "hello" != "world" ]; then echo 3; fi
if [ ! "hello" == "world" ]; then echo 4; fi
if [ 1 -lt 2 ]; then echo 5; fi
if [ 2 -le 2 ]; then echo 6; fi
if [ 2 -eq 2 ]; then echo 7; fi
if [ 3 -ge 2 ]; then echo 8; fi
if [ 3 -gt 2 ]; then echo 9; fi
if [ "hello" -ne "world" ]; then echo 10; fi
if [ "hello" -eq "hello" ]; then echo 11; fi

@daniel-sc daniel-sc self-assigned this Nov 7, 2023
@daniel-sc daniel-sc added the enhancement New feature or request label Nov 7, 2023
@daniel-sc
Copy link
Owner

Hi @monstermichl - thanks for the contribution!!
I'm not sure I understand if the added :~1 works in all cases, but I guess it makes some sense :)

@daniel-sc daniel-sc merged commit cf4bcc4 into daniel-sc:master Nov 7, 2023
6 checks passed
@monstermichl
Copy link
Contributor Author

I hope it works in all cases, but I think since each run of the FOR-loop adds a space in front, removing the first one afterwards should be fine :)

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

Successfully merging this pull request may close these issues.

2 participants