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

Some shellchecks in basic-install.sh #4088

Merged

Conversation

ChillerDragon
Copy link
Contributor

@ChillerDragon ChillerDragon commented Mar 21, 2021

By submitting this pull request, I confirm the following:
please fill any appropriate checkboxes, e.g: [X]

  • I have read and understood the contributors guide, as well as this entire template.
  • I have made only one major change in my proposed changes.
  • I have commented my proposed changes within the code.
  • I have tested my proposed changes, and have included unit tests where possible.
  • I am willing to help maintain this change if there are issues with it later.
  • I give this submission freely and claim no ownership.
  • It is compatible with the EUPL 1.2 license
  • I have squashed any insignificant commits. (git rebase)

Please make sure you Sign Off all commits. Pi-hole enforces the DCO.


What does this PR aim to accomplish?:

Since there are shellcheck magic comments to disable rules might as well fix some warnings.

I reduced the warnings from

In basic-install.sh line 189:
        detected_os=$(grep "\bID\b" /etc/os-release | cut -d '=' -f2 | tr -d '"')
                            ^-- SC1117: Backslash is literal in "\b". Prefer explicit escaping: "\\b".
                                ^-- SC1117: Backslash is literal in "\b". Prefer explicit escaping: "\\b".


In basic-install.sh line 774:
    IPV6_ADDRESSES=($(ip -6 address | grep 'scope global' | awk '{print $2}'))
                    ^-- SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).


In basic-install.sh line 1023:
    local regex="^${ipv4elem}\.${ipv4elem}\.${ipv4elem}\.${ipv4elem}${portelem}$"
                             ^-- SC1117: Backslash is literal in "\.". Prefer explicit escaping: "\\.".
                                          ^-- SC1117: Backslash is literal in "\.". Prefer explicit escaping: "\\.".
                                                       ^-- SC1117: Backslash is literal in "\.". Prefer explicit escaping: "\\.".


In basic-install.sh line 2296:
    local latesttag
          ^-- SC2034: latesttag appears unused. Verify use (or export if used externally).


In basic-install.sh line 2371:
    if which dnsmasq &> /dev/null; then
       ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.


In basic-install.sh line 2487:
    ftlLoc=$(which pihole-FTL 2>/dev/null)
             ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.


In basic-install.sh line 2504:
    if which dnsmasq &> /dev/null; then
       ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.


In basic-install.sh line 2525:
            localSha1=$(sha1sum "$(which pihole-FTL)" | cut -d ' ' -f 1)
                                   ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.


In basic-install.sh line 2555:
                localSha1=$(sha1sum "$(which pihole-FTL)" | cut -d ' ' -f 1)
                                       ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.

to

In basic-install.sh line 774:
    IPV6_ADDRESSES=($(ip -6 address | grep 'scope global' | awk '{print $2}'))
                    ^-- SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).


In basic-install.sh line 2486:
    ftlLoc=$(which pihole-FTL 2>/dev/null)
             ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.


In basic-install.sh line 2524:
            localSha1=$(sha1sum "$(which pihole-FTL)" | cut -d ' ' -f 1)
                                   ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.


In basic-install.sh line 2554:
                localSha1=$(sha1sum "$(which pihole-FTL)" | cut -d ' ' -f 1)
                                       ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.

How does this PR accomplish the above?:

I only changed the obvious fixes that are known to not make any issues. The 4 left over warnings need a bit more elaborated fix and come with possible traps. For example command -v and which handle aliases different so when the output is needed not just the return code this can change behavior if pihole-FTL is an alias.

Signed-off-by: ChillerDragon <ChillerDragon@gmail.com>
@dschaper dschaper self-assigned this Jul 21, 2021
@yubiuser
Copy link
Member

Closing and reopening to trigger the tests again.

@yubiuser yubiuser closed this Nov 24, 2021
@yubiuser yubiuser reopened this Nov 24, 2021
@yubiuser yubiuser merged commit e485a7b into pi-hole:development Dec 2, 2021
@DL6ER DL6ER mentioned this pull request Dec 22, 2021
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-ftl-v5-12-web-v5-9-and-core-v5-7-released/51795/1

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

6 participants