-
Notifications
You must be signed in to change notification settings - Fork 907
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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
You mean pull request message? The commit message is not that detailed. |
Yes, PR message, sorry. I copied it in the commit message |
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:
$var
→"$var"
Note: this isn't always necessary and I've been careful not to substitute where it wasn't necessary in meaning.
`command`
→$(command)
$(( $a + $b ))
→$(( a + b ))
cd "$dir"
→cd "$dir" || exit 1
[ check1 -o check2 ]
→[ check1 ] || [ check2 ]
cat "${file}" | wc -c
→< "${file}" wc -c
Note: this looks a bit uglier but works faster.
II. Some special changes:
utils/common.sh
:https://github.com/koalaman/shellcheck/wiki/SC2112
This script is interpreted by
sh
, not bybash
, but uses the keywordfunction
.So I replaced
#!/usr/bin/env sh
to#!/usr/bin/env bash
.#!/usr/bin/env bash
for consistency and cross-platform compatibility, especially since most of the files already use bash.#!/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:
tests/ossfuzz.sh
:https://github.com/koalaman/shellcheck/wiki/SC2162
read i
→read -r i
Note: I think that there is no need in special treatment for backslashes, but I could be wrong.
tests/do.sh.in
:https://github.com/koalaman/shellcheck/wiki/SC2035
ls *.*cap*
→ls -- *.*cap*
utils/verify_dist_tarball.sh
:https://github.com/koalaman/shellcheck/wiki/SC2268
[ "x${TARBALL}" = x ]
→[ -z "${TARBALL}" ]
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]')
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
andLIST_MERGED6
There were typos with this variables in files
utils/aws_ip_addresses_download.sh
,utils/aws_ip_addresses_download.sh
andutils/microsoft_ip_addresses_download.sh
where variableLIST6_MERGED
was defined, butLIST_MERGED6
was removed byrm
.I changed all
LIST_MERGED6
toLIST6_MERGED
.Not all changes are absolutely necessary, but some may save you from future bugs.