fix: avoid echo usage

Echo can interpret operand as an option and checking every variable to
be echoed is troublesome while with printf, if the format specifier is
present before the operand, printing as string can be enforced.
This commit is contained in:
Ben Grande 2024-08-06 18:15:24 +02:00
parent 1b2f1ba941
commit bdd4c789c1
No known key found for this signature in database
GPG key ID: 00C64E14F51F9E56
52 changed files with 318 additions and 270 deletions

View file

@ -23,15 +23,15 @@ host="${arg%%+*}"
port="${arg##*+}"
if test -z "${port}" || test -z "${host}" || test "${port}" = "${host}"; then
echo "Missing either host, port or both" >&2
printf '%s\n' "Missing either host, port or both" >&2
exit 1
fi
if test "${#host}" -gt 256; then
echo "Host size exceeds limit" >&2
printf '%s\n' "Host size exceeds limit" >&2
exit 1
fi
if test "${#port}" -gt 5 || test "${port}" -gt 65535; then
echo "Invalid port number, it must be between 1 and 65535" >&2
printf '%s\n' "Invalid port number, it must be between 1 and 65535" >&2
exit 1
fi