Skip to content
New issue

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

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

Already on GitHub? # to your account

Improve Bash code based on shellcheck feedback #4791

Merged
merged 1 commit into from
Sep 4, 2019

Conversation

matejak
Copy link
Member

@matejak matejak commented Sep 3, 2019

  • Quote find glob arguments, so they are protected from the shell.
  • Quote the whole awk command, so shellcheck is not confused by unquoted curly braces.
  • Fix a typo of file_to_inspect vs files_to_inspect.
  • Made vars expansion explicit when they are followed by square brackets,
    i.e. $x[[:space:]] to ${x}[[:space:]]
  • Separated local declarations from assignments using subsells.
    local shadows the subshell return code in those cases.
  • Removed local from the Jinja macro, as there is no function there.
  • Changed sed separator in FSTAB_TARGET_ROW definition to |, got rid of TARGET_ESCAPED.
  • Double-quoted backslashes in double quotes.
  • Commented out unused def of TARGET_OPTS.

* Quote `find` glob, arguments, so they are protected from the shell.
* Quote the whole `awk` command, so shellcheck is not confused by unquoted curly braces.
* Fix a typo of `file_to_inspect` vs `files_to_inspect`.
* Made vars expansion explicit when they are followed by square brackets,
  i.e. `$x[[:space:]]` to `${x}[[:space:]]`
* Separated `local` declarations from assignments using subsells.
  `local` shadows the subshell return code in those cases.
* Removed `local` from the Jinja macro, as there is no function there.
* Changed `sed` separator in `FSTAB_TARGET_ROW` definition to `|`, got rid of `TARGET_ESCAPED`.
* Double-quoted backslashes in double quotes.
* Commented out unused def of `TARGET_OPTS`.
@matejak matejak added the Bash Bash remediation update. label Sep 3, 2019
@matejak matejak added this to the 0.1.47 milestone Sep 3, 2019
@jan-cerny jan-cerny self-assigned this Sep 4, 2019
@jan-cerny jan-cerny changed the title Improved Bash code based on shellcheck feedback. Improved Bash code based on shellcheck feedback Sep 4, 2019
@jan-cerny jan-cerny changed the title Improved Bash code based on shellcheck feedback Improve Bash code based on shellcheck feedback Sep 4, 2019
@jan-cerny jan-cerny merged commit 7a215a1 into ComplianceAsCode:master Sep 4, 2019
@matejak matejak deleted the bash_style3 branch October 9, 2019 11:46
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bash Bash remediation update.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants