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 Correct if syntax #167

Merged
merged 4 commits into from
Sep 28, 2024
Merged

fix Correct if syntax #167

merged 4 commits into from
Sep 28, 2024

Conversation

prsabahrami
Copy link
Contributor

Closes #166

certik and others added 2 commits September 27, 2024 14:42
The test script `if_else.sh` has incorrect syntax for an if statement:

    $ bash if_else.sh
    if_else.sh: line 2: syntax error near unexpected token `then'
    if_else.sh: line 2: `if [[ $FOO -eq 1 ]] then'

The correct syntax uses `;` before `then`.
@prsabahrami prsabahrami changed the title Correct if syntax fix Correct if syntax Sep 28, 2024
Copy link

codecov bot commented Sep 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.46%. Comparing base (1113c78) to head (6a61a98).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #167      +/-   ##
==========================================
+ Coverage   58.05%   61.46%   +3.40%     
==========================================
  Files          29       29              
  Lines        2818     2818              
==========================================
+ Hits         1636     1732      +96     
+ Misses       1182     1086      -96     
Flag Coverage Δ
61.46% <ø> (+3.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@certik
Copy link
Contributor

certik commented Sep 28, 2024

Let's test all of the combinations:

FOO=2
if [[ $FOO -eq 1 ]]; then
    echo "FOO is 1";
elif [[ $FOO -eq 2 ]]; then
    echo "FOO is 2";
else
    echo "FOO is not 1 or 2";
fi

and

FOO=2
if [[ $FOO -eq 1 ]]; then
    echo "FOO is 1"
elif [[ $FOO -eq 2 ]]; then
    echo "FOO is 2"
else
    echo "FOO is not 1 or 2"
fi

and

FOO=2
if [[ $FOO -eq 1 ]];
then
    echo "FOO is 1";
elif [[ $FOO -eq 2 ]];
then
    echo "FOO is 2";
else
    echo "FOO is not 1 or 2";
fi

and

FOO=2
if [[ $FOO -eq 1 ]]
then
    echo "FOO is 1";
elif [[ $FOO -eq 2 ]]
then
    echo "FOO is 2";
else
    echo "FOO is not 1 or 2";
fi

@prsabahrami
Copy link
Contributor Author

prsabahrami commented Sep 28, 2024

I'll just create a way for the scripts in script folder to be tested. That would be easier I believe.

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, I think this looks great now!

@prsabahrami
Copy link
Contributor Author

Agreed.
I'll go ahead and merge this then.

@prsabahrami prsabahrami merged commit c35f348 into main Sep 28, 2024
9 checks passed
@prsabahrami prsabahrami deleted the correct_if_syntax branch September 28, 2024 23:57
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.

Use the correct syntax for if
2 participants