Skip to content

Improve Bash code based on shellcheck feedback#4791

Merged
jan-cerny merged 1 commit intoComplianceAsCode:masterfrom
matejak:bash_style3
Sep 4, 2019
Merged

Improve Bash code based on shellcheck feedback#4791
jan-cerny merged 1 commit intoComplianceAsCode:masterfrom
matejak:bash_style3

Conversation

@matejak
Copy link
Copy Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bash Bash remediation update.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants