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

[Proposal]: Use ShellCheck for the Linux/Mac script #11

Open
YisusChrist opened this issue Jul 15, 2023 · 1 comment
Open

[Proposal]: Use ShellCheck for the Linux/Mac script #11

YisusChrist opened this issue Jul 15, 2023 · 1 comment

Comments

@YisusChrist
Copy link

YisusChrist commented Jul 15, 2023

It is not always mandatory, but using some external tools such as ShellCheck can help to find potential bugs and risks in the shell code that is produced by the Instl script.

This is the report generated for the username/reponame script:

[Line 1:](javascript:setPosition(1, 1))
################################################################################
^-- [SC2148](https://www.shellcheck.net/wiki/SC2148) (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
 
[Line 230:](javascript:setPosition(230, 10))
  alias "${1}$2"="$3"
         ^-- [SC2139](https://www.shellcheck.net/wiki/SC2139) (warning): This expands when defined, not when used. Consider escaping.
 
[Line 242:](javascript:setPosition(242, 19))
  alias -p | grep $1 | cut -d'=' -f1 | awk -F"$1" '{print $2; }'
                  ^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.

Did you mean: ([apply this](javascript:applyFixIndex([2])), apply [all SC2086](javascript:applyFixCode(2086)))
  alias -p | grep "$1" | cut -d'=' -f1 | awk -F"$1" '{print $2; }'
 
[Line 265:](javascript:setPosition(265, 10))
mkdir -p $binaryLocation
         ^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.

Did you mean: ([apply this](javascript:applyFixIndex([3])), apply [all SC2086](javascript:applyFixCode(2086)))
mkdir -p "$binaryLocation"
 
[Line 274:](javascript:setPosition(274, 10))
mkdir -p $installLocation
         ^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.

Did you mean: ([apply this](javascript:applyFixIndex([4])), apply [all SC2086](javascript:applyFixCode(2086)))
mkdir -p "$installLocation"
 
[Line 313:](javascript:setPosition(313, 16))
getReleaseArgs=$curlOpts
               ^-- [SC2128](https://www.shellcheck.net/wiki/SC2128) (warning): Expanding an array without an index only gives the first element.
 
[Line 315:](javascript:setPosition(315, 21))
releaseJSON="$(curl ${getReleaseArgs[@]})"
                    ^-- [SC2068](https://www.shellcheck.net/wiki/SC2068) (error): Double quote array expansions to avoid re-splitting elements.
 
[Line 340:](javascript:setPosition(340, 6))
if [ $arch == "x86_64" ]; then
     ^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.

Did you mean: ([apply this](javascript:applyFixIndex([7])), apply [all SC2086](javascript:applyFixCode(2086)))
if [ "$arch" == "x86_64" ]; then
 
[Line 342:](javascript:setPosition(342, 8))
elif [ $arch == "i386" ] || [ $arch == "i686" ]; then
       ^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
                              ^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.

Did you mean: ([apply this](javascript:applyFixIndex([8,9])), apply [all SC2086](javascript:applyFixCode(2086)))
elif [ "$arch" == "i386" ] || [ "$arch" == "i686" ]; then
 
[Line 366:](javascript:setPosition(366, 22))
  currentOsAliases+=(${linux[@]})
                     ^-- [SC2206](https://www.shellcheck.net/wiki/SC2206) (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
 
[Line 368:](javascript:setPosition(368, 22))
  currentOsAliases+=(${darwin[@]})
                     ^-- [SC2206](https://www.shellcheck.net/wiki/SC2206) (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
 
[Line 415:](javascript:setPosition(415, 8))
  if [ $score -gt $maxScore ]; then
       ^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.
                  ^-- [SC2086](https://www.shellcheck.net/wiki/SC2086) (info): Double quote to prevent globbing and word splitting.

Did you mean: ([apply this](javascript:applyFixIndex([12,13])), apply [all SC2086](javascript:applyFixCode(2086)))
  if [ "$score" -gt "$maxScore" ]; then
 
[Line 429:](javascript:setPosition(429, 19))
downloadAssetArgs=$curlOpts
                  ^-- [SC2128](https://www.shellcheck.net/wiki/SC2128) (warning): Expanding an array without an index only gives the first element.
 
[Line 431:](javascript:setPosition(431, 6))
curl ${downloadAssetArgs[@]}
     ^-- [SC2068](https://www.shellcheck.net/wiki/SC2068) (error): Double quote array expansions to avoid re-splitting elements.

As I said, It is not always mandatory but the team should definitely take a look at these warnings and errors reported that may help to make the script more safe.

@MarvinJWendt
Copy link
Member

Hi, sorry for the late reply. Instl was not maintained, but I want to give it some attention now, as I still think the project idea is awesome.

We will definitely include a linter now, and generally improve the scripts.

@MarvinJWendt MarvinJWendt changed the title Suggestion for using ShellCheck for the Linux/Mac script [Proposal]: Use ShellCheck for the Linux/Mac script Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants