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 * Put utility flags in the ASCII order and **don't** group them together. For
example, `ls -1 -A -q`. 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. * `snake_case`, not `camelCase` for variables. `kebab-case` for filenames.
* UPPERCASE names for external exported variables, lowercase for local, * UPPERCASE names for external exported variables, lowercase for local,
@ -319,6 +322,14 @@ on GitHub and most other Markdown renderers. -->
dir="${TOP_DIR}"/sub 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> ## <a id="text-including-comments" href="#text-including-comments">Text, Including Comments</a>
* End sentences with appropriate punctuation. * End sentences with appropriate punctuation.

View File

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

View File

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

View File

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

View File

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

View File

@ -157,8 +157,7 @@ ineffassign ./...
unparam ./... unparam ./...
git ls-files -- '*.go' '*.md' '*.mod' '*.sh' '*.yaml' '*.yml'\ git ls-files -- '*.go' '*.md' '*.mod' '*.sh' '*.yaml' '*.yml' 'Makefile'\
'Makefile'\
| xargs misspell --error | xargs misspell --error
looppointer ./... 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 # Don't use quotes with flag variables because we want an empty space if
# those aren't set. # those aren't set.
"$go" test $count_flags $cover_flags $race_flags $timeout_flags\ "$go" test $count_flags $cover_flags $race_flags $timeout_flags $x_flags $v_flags ./...
$x_flags $v_flags ./...