Make separating newline trailing not leading

Seems like newer shellcheck complains more, so disable another false positive
and move `disable' directives into the script.

Replace [ with [[ and (( while here.
This commit is contained in:
kn 2022-12-23 13:35:48 +00:00
parent 02dc326491
commit f1f095ee3e
2 changed files with 15 additions and 9 deletions

View File

@ -2,9 +2,8 @@ COMMENT = query portroach(1)
CATEGORIES = sysutils
DISTFILES = # empty
# <portroach API>.rev
PKGNAME = portroach-cli-1.7
PKGNAME = portroach-cli-1.8
MAINTAINER = Klemens Nanni <kn@openbsd.org>
REVISION = 0
# ISC
PERMIT_PACKAGE = Yes
@ -23,7 +22,7 @@ do-install:
do-test:
ksh -n ${SCRIPT}
shellcheck -Cnever -e SC2250 --norc -o all -S style ${SCRIPT}
shellcheck --color=never --norc --enable=all --severity=style ${SCRIPT}
mandoc -Tlint ${MAN}
.include <bsd.port.mk>

View File

@ -1,6 +1,6 @@
#!/bin/ksh
#
# Copyright (c) 2021 Klemens Nanni <kn@openbsd.org>
# Copyright (c) 2021-2022 Klemens Nanni <kn@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@ -14,6 +14,12 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# no, do not prefer braces around variables
# shellcheck disable=SC2250
# ksh does not implicitly disable errexit in command substitution
# shellcheck disable=SC2311
set -Cefu -o pipefail
readonly self=${0##*/}
@ -68,7 +74,7 @@ done
shift $((OPTIND - 1))
$pflag && ! $Uflag && ! $mflag && usage
$uflag && [[ $url != @(file|ftp|http|https)://* ]] && err 'invalid url'
[ $# -eq 0 ] || usage
(($# == 0)) || usage
if $Uflag || $mflag
then
@ -91,12 +97,13 @@ then
# `show_ports()' always yields at least one port unless `-p'
# fails to match any of their PKGPATHs
if [ -n "$ports" ]
if [[ -n $ports ]]
then
printf '\n===>\t%s\n' "$match"
printf '%s\t%s\t%s\t%s\n%s' BASE_PKGPATH VERSION NEW \
HOMEPAGE/COMMENT "$ports" |
printf '===>\t%s\n' "$match"
printf 'BASE_PKGPATH\tVERSION\tNEW\tHOMEPAGE/COMMENT\n'
printf '%s' "$ports" |
column -tc4 -s' '
printf '\n'
fi
done
else