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

shell: reformatted, fixed inspections, typos #2506

Merged
merged 1 commit into from
Jul 18, 2024
Merged

shell: reformatted, fixed inspections, typos #2506

merged 1 commit into from
Jul 18, 2024

Conversation

pasabanov
Copy link
Contributor

Please sign (check) the below before submitting the Pull Request:

#1986 #2006 #2113

Describe changes:

Reformatted shell scripts according to ShellCheck.

I. Most common changes:

  1. https://github.com/koalaman/shellcheck/wiki/SC2086
    $var"$var"
    Note: this isn't always necessary and I've been careful not to substitute where it wasn't necessary in meaning.
  2. https://github.com/koalaman/shellcheck/wiki/SC2006
    `command`$(command)
  3. https://github.com/koalaman/shellcheck/wiki/SC2004
    $(( $a + $b ))$(( a + b ))
  4. https://github.com/koalaman/shellcheck/wiki/SC2164
    cd "$dir"cd "$dir" || exit 1
  5. https://github.com/koalaman/shellcheck/wiki/SC2166
    [ check1 -o check2 ][ check1 ] || [ check2 ]
  6. https://github.com/koalaman/shellcheck/wiki/SC2002
    cat "${file}" | wc -c< "${file}" wc -c
    Note: this looks a bit uglier but works faster.

II. Some special changes:

  1. In file utils/common.sh:
    https://github.com/koalaman/shellcheck/wiki/SC2112
    This script is interpreted by sh, not by bash, but uses the keyword function.
    So I replaced #!/usr/bin/env sh to #!/usr/bin/env bash.
  2. After that I thought of replacing all shebangs to #!/usr/bin/env bash for consistency and cross-platform compatibility, especially since most of the files already use bash.
  3. But in cases when it was #!/bin/sh -e or #!/bin/bash -eu another problem appears:
    https://github.com/koalaman/shellcheck/wiki/SC2096
    So I decided to make all shebangs look uniform:
    #!/usr/bin/env bash
    set -e (or set -eu) (if needed)
    
  4. In file tests/ossfuzz.sh:
    https://github.com/koalaman/shellcheck/wiki/SC2162
    read iread -r i
    Note: I think that there is no need in special treatment for backslashes, but I could be wrong.
  5. In file tests/do.sh.in:
    https://github.com/koalaman/shellcheck/wiki/SC2035
    ls *.*cap*ls -- *.*cap*
  6. In file utils/verify_dist_tarball.sh:
    https://github.com/koalaman/shellcheck/wiki/SC2268
    [ "x${TARBALL}" = x ][ -z "${TARBALL}" ]
  7. In file utils/check_symbols.sh:
    https://github.com/koalaman/shellcheck/wiki/SC2221
    '[ndpi_utils.o]'|'[ndpi_memory.o]'|'[roaring.o]')'[ndpi_utils.o]'|'[ndpi_memory.o]')
  8. In file autogen.sh:
    https://github.com/koalaman/shellcheck/wiki/SC2145
    echo "./configure $@"echo "./configure $*"
    https://github.com/koalaman/shellcheck/wiki/SC2068
    ./configure $@./configure "$@"

III. LIST6_MERGED and LIST_MERGED6
There were typos with this variables in files utils/aws_ip_addresses_download.sh, utils/aws_ip_addresses_download.sh and utils/microsoft_ip_addresses_download.sh where variable LIST6_MERGED was defined, but LIST_MERGED6 was removed by rm.
I changed all LIST_MERGED6 to LIST6_MERGED.

Not all changes are absolutely necessary, but some may save you from future bugs.

@IvanNardi IvanNardi requested a review from utoni July 17, 2024 14:20
autogen.sh Outdated Show resolved Hide resolved
autogen.sh Show resolved Hide resolved
Copy link
Collaborator

@utoni utoni left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@IvanNardi IvanNardi left a comment

Choose a reason for hiding this comment

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

Particularly appreciated the detailed commit message

@IvanNardi IvanNardi merged commit c35a5ca into ntop:dev Jul 18, 2024
35 checks passed
@pasabanov
Copy link
Contributor Author

Particularly appreciated the detailed commit message

You mean pull request message?

The commit message is not that detailed.

@IvanNardi
Copy link
Collaborator

Particularly appreciated the detailed commit message

You mean pull request message?

The commit message is not that detailed.

Yes, PR message, sorry. I copied it in the commit message

@pasabanov pasabanov deleted the bash_fixes branch July 18, 2024 16:28
@pasabanov pasabanov restored the bash_fixes branch July 18, 2024 16:28
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.

3 participants