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

lint: fix shellcheck findings in embedded shell scripts #552

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Okeanos
Copy link
Contributor

@Okeanos Okeanos commented May 20, 2023

  • prevent wordsplitting and accidental globbling by quoting variables
  • use parameter expansion with braces for consistency
  • remove a number of useless cat-expressions
  • use printf with format string syntax

vmware:

@travier
Copy link
Member

travier commented May 21, 2023

That looks great! Thanks a lot. I'll do an deeper review soon.

modules/ROOT/pages/provisioning-exoscale.adoc Outdated Show resolved Hide resolved
modules/ROOT/pages/provisioning-qemu.adoc Outdated Show resolved Hide resolved
modules/ROOT/pages/provisioning-qemu.adoc Outdated Show resolved Hide resolved
modules/ROOT/pages/provisioning-vmware.adoc Show resolved Hide resolved
modules/ROOT/pages/provisioning-vmware.adoc Show resolved Hide resolved
modules/ROOT/pages/provisioning-vmware.adoc Outdated Show resolved Hide resolved
Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

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

Hmm. I'm a bit torn here. While I see value in making things more correct and observing good practices I also feel like a lot of these changes make things harder to read. All the extra quoting and brackets disrupt the flow as you are reading the docs and makes the lines go longer which means users will more often need to scroll.

Should we focus our efforts here on cases where there is a higher chance of one of these problems happening?

modules/ROOT/pages/provisioning-exoscale.adoc Outdated Show resolved Hide resolved
@Okeanos
Copy link
Contributor Author

Okeanos commented May 23, 2023

Hmm. I'm a bit torn here. While I see value in making things more correct and observing good practices I also feel like a lot of these changes make things harder to read. All the extra quoting and brackets disrupt the flow as you are reading the docs and makes the lines go longer which means users will more often need to scroll.

Should we focus our efforts here on cases where there is a higher chance of one of these problems happening?

I absolutely understand and I definitely see the value and validity in your review findings. Given the necessity to extract the shell blocks from the asciidoc surroundings to be able to use shellshock at all, loss of context was inevitable and a certainly lead to being overaggressive in seeing & applying suggestions.

I'll go over your findings, fix them – especially the quotes surrounding $() blocks (I really shouldn't have applied these in the first place … d'oh) for example – and then we'll see what else can be made nicer to read.

@travier
Copy link
Member

travier commented May 24, 2023

Let's focus on the cases where there is a potential for issue (space in file path for example) first and we'll see what to do for the other ones later.

@Okeanos Okeanos force-pushed the fix-shellcheck-warnings branch 3 times, most recently from 4702c3b to 27ff67a Compare May 24, 2023 20:11
@Okeanos
Copy link
Contributor Author

Okeanos commented May 24, 2023

Let's focus on the cases where there is a potential for issue (space in file path for example) first and we'll see what to do for the other ones later.

I think I removed most if not all quotes and additional curly braces where I could reasonably deduce/assume that the variable's value in question is very much unlikely to contain whitespace characters (or other shell-relevant characters like #).

At the same time I took the liberty (duck) of making the coreos-installer invocations reasonably consistent across the pages to offer a more consistent reading experience. I can revert those though if it makes the change set too noisy or is deemed frivolous.

The virt-install and qemu-kvm commands are a little tricky – we put (sometimes nested multiple times and then unwrapped at invocation time) variables in them that will absolutely contain path expressions (such as ${PWD}) that are likely to contain spaces themselves. That's quoting hell in a nutshell. While I am tempted to "fix" this … I am not sure it's worth it given that these commands are likely not going to be executed by novices who'll stumble across this. I am overall just as willing to forgo quotes altogether here to not make it even weirder.

Please don't hesitate to call out anything else you want changed – I essentially took it upon myself to do this so no hard feeling if you want it differently or not at all.

- prevent wordsplitting and accidental globbling by quoting variables
- use parameter expansion with braces for consistency where prudent
- remove a number of useless cat-expressions
- replace printf with echo for fewer differences across examples
- align coreos-installer snippets for a more consistent reading experience

vmware:
- use correct gzip file ending (See coreos#524 (comment) for details) in example
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

This looks like a good overall improvement.
Thanks for working on it!

I'll give some time for others to have a look before merging.

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.

None yet

4 participants