From 44b1e103b4d3a24aee89587ef302891e9f9c3807 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 17 Feb 2023 15:07:30 -0300 Subject: bin/: Use explicit "--" separator for assert-arg usages In order to prevent legitimate cases to fail as errors, such as: NUM='-10' eval "$(assert-arg "$NUM" '-n NUM')" To prevent assert-arg(1) from treating "-10" as the options "-1 and -0, they need to be put after the "--" separator. This way, all usages of assert-arg(1) that had its first argument as a variable were adapted, and the usage and examples of assert-arg itself were updated to encourage this best practice. --- bin/assert-arg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/assert-arg') diff --git a/bin/assert-arg b/bin/assert-arg index d7bc8f4..3c8990a 100755 --- a/bin/assert-arg +++ b/bin/assert-arg @@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - assert-arg STRING MESSAGE + assert-arg -- STRING MESSAGE assert-arg -h EOF } @@ -23,7 +23,7 @@ help() { Assert that $1 contains an argument, named FILENAME: - $ eval "$(assert-arg "${1:-}" 'FILENAME')" + $ eval "$(assert-arg -- "${1:-}" 'FILENAME')" EOF } -- cgit v1.2.3