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/msg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin/msg') diff --git a/bin/msg b/bin/msg index 0f9cced..84d25a7 100755 --- a/bin/msg +++ b/bin/msg @@ -124,22 +124,22 @@ fi MESSAGE="${1:-}" if [ "$XMPP" = true ]; then - eval "$(assert-arg "$MESSAGE" '-X MESSAGE')" + eval "$(assert-arg -- "$MESSAGE" '-X MESSAGE')" xmpp -m "$MESSAGE" eu@euandre.org & fi if [ "$SOUND" = true ]; then sound & fi if [ "$SPEAK" = true ]; then - eval "$(assert-arg "$MESSAGE" '-S MESSAGE')" + eval "$(assert-arg -- "$MESSAGE" '-S MESSAGE')" echo "$MESSAGE" | speak -v pt-BR & fi if [ "$MAIL" = true ]; then - eval "$(assert-arg "$MESSAGE" '-m MESSAGE')" + eval "$(assert-arg -- "$MESSAGE" '-m MESSAGE')" echo " " | email -s "$MESSAGE" eu@euandre.org & fi if [ "$DESKTOP" = true ]; then - eval "$(assert-arg "$MESSAGE" '-D MESSAGE')" + eval "$(assert-arg -- "$MESSAGE" '-D MESSAGE')" if [ "$OK" = true ]; then notify-send -t 5000 "$MESSAGE" & else -- cgit v1.2.3