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

Linting scripts with shellcheck #11

Open
MakisH opened this issue Jul 31, 2023 · 3 comments
Open

Linting scripts with shellcheck #11

MakisH opened this issue Jul 31, 2023 · 3 comments

Comments

@MakisH
Copy link
Member

MakisH commented Jul 31, 2023

You may want to try shellcheck. For setup.sh, it only gives two issues, but it can be quite helpful in other cases:

~/repos/precice/nix-packages [master]$ shellcheck setup.sh 

In setup.sh line 17:
if [ "$(grep 'export PATH=$PATH:$HOME/.bin' "$HOME/.profile" -c)" -eq 0 ]; then
             ^----------------------------^ SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.


In setup.sh line 18:
  echo 'export PATH=$PATH:$HOME/.bin' >> "$HOME/.profile"
       ^----------------------------^ SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.

For more information:
  https://www.shellcheck.net/wiki/SC2016 -- Expressions don't expand in singl...
@MakisH
Copy link
Member Author

MakisH commented Jul 31, 2023

Looking at this line, you may also want to prepend, instead of appending, as the system would then look at the Nix binaries first:

export PATH=$HOME/.bin:$PATH

@cheriimoya
Copy link
Collaborator

Here, we actually want the single quotes, as we really want to grep for this exact string without expanding it. But having shellcheck is probably a good idea anyway.

For the prepending part: I am unsure if this is a good idea. The way it is, it will first take a natively installed nix binary, if available and then fallback to the binary that was installed by using the setup.sh script. What are your thoughts on this?

@MakisH
Copy link
Member Author

MakisH commented Sep 3, 2023

For the prepending part: I am unsure if this is a good idea. The way it is, it will first take a natively installed nix binary, if available and then fallback to the binary that was installed by using the setup.sh script. What are your thoughts on this?

I would assume that a user installation of nix has priority over the system installation. If the user needed to install a different version locally, there was probably a reason, such as a problem or missing feature of the system installation.

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

No branches or pull requests

2 participants