Skip to content

RFC: Style and shellchecks#13542

Closed
zimbatm wants to merge 4 commits intoNixOS:masterfrom
zimbatm:style-and-shellchecks
Closed

RFC: Style and shellchecks#13542
zimbatm wants to merge 4 commits intoNixOS:masterfrom
zimbatm:style-and-shellchecks

Conversation

@zimbatm
Copy link
Copy Markdown
Member

@zimbatm zimbatm commented Feb 28, 2016

Things done:
  • Tested using sandboxing (nix-build --option build-use-chroot true or nix.useChroot on NixOS)
  • Built on platform(s): NixOS / OSX / Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Using ShellCheck to make sure all of our bash is escaped properly. Is this something desirable ?

There are a couple of things I see as controversial in these changes:

Use #!bash is a hack that lets vim and shellcheck know that we are dealing with a bash dialect. The file itself is not executable because a shebang needs an absolute path (thus /usr/bin/env's existance).

Use [[ ]] over the POSIX [ ] or test syntax. Mainly because it's smarter in regards to escaping and less likely to mis-use.

A new --unset option that I bundle with these changes because of the mass-rebuild.


This is not done yet, just seeking for confirmation if this is a good idea or not. Also trying to see if we can agree on a bash style.

/cc @edolstra @domenkozar

`--set FOO ""` is not strictly equivalent to `--unset FOO`. In the former case
the environment variable still exists with an empty string as a value.
@mention-bot
Copy link
Copy Markdown

By analyzing the blame information on this pull request, we identified @edolstra, @ttuegel and @nbp to be potential reviewers

echo exec ${argv0:+-a $argv0} "$original" \
$flagsBefore '"${extraFlagsArray[@]}"' '"$@"' >> $wrapper
echo "exec ${argv0:+-a $argv0 }$original" \
"$flagsBefore" '"${extraFlagsArray[@]}"' '"$@"' >> "$wrapper"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I need to fix the escaping of $flagsBefore here

@ttuegel
Copy link
Copy Markdown
Member

ttuegel commented Feb 28, 2016

These are mass-rebuilding changes; please make this PR against the staging branch.

@zimbatm
Copy link
Copy Markdown
Member Author

zimbatm commented Feb 28, 2016

Okay. Should I re-open another PR ? I don't think github allows me to switch the target.

@edolstra
Copy link
Copy Markdown
Member

Looks good. Didn't know that quotes are unnecessary in [[ ... ]] tests.

@dezgeg
Copy link
Copy Markdown
Contributor

dezgeg commented Feb 28, 2016

Use [[ ]] over the POSIX [ ] or test syntax. Mainly because it's smarter in regards to escaping and less likely to mis-use.

IMHO [[ ]] is not better - you need to learn totally new quoting rules for that, e.g.
d844a10

@ttuegel
Copy link
Copy Markdown
Member

ttuegel commented Feb 28, 2016

Should I re-open another PR ? I don't think github allows me to switch the target.

Yes. Sorry!

@zimbatm zimbatm mentioned this pull request Feb 28, 2016
5 tasks
@zimbatm
Copy link
Copy Markdown
Member Author

zimbatm commented Feb 28, 2016

Alright, everyone to the batmobile ! #13543

@zimbatm zimbatm closed this Feb 28, 2016
@zimbatm zimbatm deleted the style-and-shellchecks branch March 6, 2016 19:50
@nbp nbp mentioned this pull request Feb 26, 2017
4 tasks
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.

5 participants