Pull request: all: imp shell code

Merge in DNS/adguard-home from imp-sh to master

Squashed commit of the following:

commit 212f03f3d6e0824428c28ffd79cac8f5ea271d9c
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Apr 9 14:51:59 2021 +0300

    all: imp shell code
This commit is contained in:
Ainar Garipov 2021-04-09 15:07:18 +03:00
parent 6a8f6357e2
commit 0247a2da44
7 changed files with 23 additions and 20 deletions

View file

@ -289,6 +289,9 @@ on GitHub and most other Markdown renderers. -->
* Put utility flags in the ASCII order and **don't** group them together. For
example, `ls -1 -A -q`.
* Script code lines should not be longer than one hundred (**100**) columns.
For comments, see the text section below.
* `snake_case`, not `camelCase` for variables. `kebab-case` for filenames.
* UPPERCASE names for external exported variables, lowercase for local,
@ -319,6 +322,14 @@ on GitHub and most other Markdown renderers. -->
dir="${TOP_DIR}"/sub
```
* When using `test` (aka `[`), spell compound conditions with `&&`, `||`, and
`!` **outside** of `test` instead of `-a`, `-o`, and `!` inside of `test`
correspondingly. The latter ones are pretty much deprecated in POSIX.
See also: “[Problems With the `test` Builtin: What Does `-a` Mean?]”.
[Problems With the `test` Builtin: What Does `-a` Mean?]: https://www.oilshell.org/blog/2017/08/31.html
## <a id="text-including-comments" href="#text-including-comments">Text, Including Comments</a>
* End sentences with appropriate punctuation.

View file

@ -200,7 +200,7 @@
set -e -f -u -x
export CHANNEL="${bamboo.channel}"
if [ "$CHANNEL" != 'release' -a "${CHANNEL}" != 'beta' ]
if [ "$CHANNEL" != 'release' ] && [ "${CHANNEL}" != 'beta' ]
then
echo "don't publish to Github Releases for this channel"

View file

@ -18,7 +18,7 @@ readonly channel="$CHANNEL"
readonly commit="$COMMIT"
readonly dist_dir="$DIST_DIR"
if [ "${VERSION:-}" = 'v0.0.0' -o "${VERSION:-}" = '' ]
if [ "${VERSION:-}" = 'v0.0.0' ] || [ "${VERSION:-}" = '' ]
then
readonly version="$(sh ./scripts/make/version.sh)"
else

View file

@ -48,7 +48,7 @@ readonly channel="$CHANNEL"
# Check VERSION against the default value from the Makefile. If it is
# that, use the version calculation script.
if [ "${VERSION:-}" = 'v0.0.0' -o "${VERSION:-}" = '' ]
if [ "${VERSION:-}" = 'v0.0.0' ] || [ "${VERSION:-}" = '' ]
then
readonly version="$(sh ./scripts/make/version.sh)"
else
@ -103,8 +103,8 @@ log "checking tools"
# Make sure we fail gracefully if one of the tools we need is missing.
for tool in gpg gzip sed sha256sum snapcraft tar zip
do
which "$tool" >/dev/null ||\
{ log "pieces don't fit, '$tool' not found"; exit 1; }
which "$tool" >/dev/null\
|| { log "pieces don't fit, '$tool' not found"; exit 1; }
done
# Data section. Arrange data into space-separated tables for read -r to
@ -219,7 +219,7 @@ build() {
log "$build_archive"
if [ "$build_snap" = '0' -o "$snap_enabled" = '0' ]
if [ "$build_snap" = '0' ] || [ "$snap_enabled" = '0' ]
then
return
fi
@ -262,8 +262,7 @@ build() {
# output, but only show it when snapcraft actually fails.
set +e
build_snapcraft_output="$(
snapcraft pack "$build_snap_dir"\
--output "$build_snap_output" 2>&1
snapcraft pack "$build_snap_dir" --output "$build_snap_output" 2>&1
)"
build_snapcraft_exit_code="$?"
set -e
@ -334,10 +333,7 @@ log "calculating checksums"
(
cd "./${dist}"
files="$( \
find . ! -name . -prune\
\( -name '*.tar.gz' -o -name '*.zip' \)
)"
files="$( find . ! -name . -prune \( -name '*.tar.gz' -o -name '*.zip' \) )"
# Don't use quotes to get word splitting.
sha256sum $files > ./checksums.txt
@ -385,8 +381,7 @@ echo "
# Same as with checksums above, don't use ls, because files matching one
# of the patterns may be absent.
readonly ar_files="$( \
find "./${dist}/" ! -name "${dist}" -prune\
\( -name '*.tar.gz' -o -name '*.zip' \)
find "./${dist}/" ! -name "${dist}" -prune \( -name '*.tar.gz' -o -name '*.zip' \)
)"
readonly ar_files_len="$(echo "$ar_files" | wc -l)"

View file

@ -106,8 +106,7 @@ fi
export CGO_ENABLED="$cgo_enabled"
export GO111MODULE='on'
readonly build_flags="${BUILD_FLAGS:-$race_flags $out_flags $par_flags\
$v_flags $x_flags}"
readonly build_flags="${BUILD_FLAGS:-$race_flags $out_flags $par_flags $v_flags $x_flags}"
# Don't use quotes with flag variables to get word splitting.
"$go" generate $v_flags $x_flags ./main.go

View file

@ -157,8 +157,7 @@ ineffassign ./...
unparam ./...
git ls-files -- '*.go' '*.md' '*.mod' '*.sh' '*.yaml' '*.yml'\
'Makefile'\
git ls-files -- '*.go' '*.md' '*.mod' '*.sh' '*.yaml' '*.yml' 'Makefile'\
| xargs misspell --error
looppointer ./...

View file

@ -39,5 +39,4 @@ readonly count_flags='--count 1'
# Don't use quotes with flag variables because we want an empty space if
# those aren't set.
"$go" test $count_flags $cover_flags $race_flags $timeout_flags\
$x_flags $v_flags ./...
"$go" test $count_flags $cover_flags $race_flags $timeout_flags $x_flags $v_flags ./...