You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fixing some style issues in shell scripts with shellcheck #77290
There are some style issues in shell scripts in this repository. ShellCheck is an useful tool to find bugs in shell scripts.
One could run git ls-files '*.sh' to find all shell script files and pipe the result to xargs shellcheck.
Or just fix it file-by-file.
Note that this issue doesn't talk about including shellcheck tests in CI.
Just a question, I've reached src/ci/docker/scripts/android-start-emulator.sh, which starts with a shebang referencing #!/bin/sh instead of the usual #!/usr/bin/env bash, and then goes on to use &>, which shellcheck warns is not a thing on POSIX sh. Should this be changed to bash or is there a reason for this?
Also, what should I do about the unused variables that pop up here and there? Some like TARGET seem like they might be nice keeping if not just for making the file follow the same structure as the others, but since they're unused I'm not sure if I should delete them.
@sasurau4 the PR wasn't abandoned, it was rejected because it wasn't clear the improvements were worth the potential breakage. I see in #78666 you only fixed warnings shellcheck marked as 'error's, that might have a better chance.
Triage: #78666 fixed the shellcheck errors and I don't think it's much worth applying shellcheck's suggestions to our source, while fighting a lot of regressions, so I'm going to close the issue. Thanks!
Activity
pta2002 commentedon Sep 28, 2020
Can I have a go at this? I think I can work on it.
tesuji commentedon Sep 28, 2020
Sure. But it's known that there are some false-positive suggestions in shellcheck.
Most of them should be caught by CI (by falling to execute).
pta2002 commentedon Sep 28, 2020
Alright, I'll have a look at what fails CI then!
pta2002 commentedon Sep 28, 2020
Just a question, I've reached src/ci/docker/scripts/android-start-emulator.sh, which starts with a shebang referencing #!/bin/sh instead of the usual #!/usr/bin/env bash, and then goes on to use &>, which shellcheck warns is not a thing on POSIX sh. Should this be changed to bash or is there a reason for this?
rust/src/ci/docker/scripts/android-start-emulator.sh
Line 1 in fc2daaa
pta2002 commentedon Sep 28, 2020
Also, what should I do about the unused variables that pop up here and there? Some like TARGET seem like they might be nice keeping if not just for making the file follow the same structure as the others, but since they're unused I'm not sure if I should delete them.
tesuji commentedon Sep 29, 2020
Just use
2>&1instead. I don't know if android has bash, so let's keep it sh.You could grep for the unused variables in
src/ci.Most of them should be passed via environment variables.
You could ignore unused var warnings.
pta2002 commentedon Sep 29, 2020
So if they're unused they should probably be exported then, no? The ones shellcheck is warning about aren't
tesuji commentedon Sep 29, 2020
You could remove it. File a draft PR to see if it run successfully.
sasurau4 commentedon Nov 2, 2020
The previous PR seems abondoned, I'll try it.
jyn514 commentedon Nov 2, 2020
@sasurau4 the PR wasn't abandoned, it was rejected because it wasn't clear the improvements were worth the potential breakage. I see in #78666 you only fixed warnings shellcheck marked as 'error's, that might have a better chance.
Rollup merge of rust-lang#78666 - sasurau4:fix/shellcheck-error, r=jy…
Rollup merge of rust-lang#78666 - sasurau4:fix/shellcheck-error, r=jy…
sjakobi commentedon Mar 26, 2021
Is there still work to do here now that #78666 has been merged?
JohnTitor commentedon Mar 31, 2021
Triage: #78666 fixed the shellcheck errors and I don't think it's much worth applying shellcheck's suggestions to our source, while fighting a lot of regressions, so I'm going to close the issue. Thanks!