From 1c3ff57ac6086b3ff91d3c66de878a66e2493bc0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 7 Dec 2014 02:29:31 -0500 Subject: chardiff: fix, escape possible printf flags --- chardiff.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chardiff.sh b/chardiff.sh index c79a102..971f24c 100644 --- a/chardiff.sh +++ b/chardiff.sh @@ -15,8 +15,8 @@ wdiff_getopt() { -e '/=/{ s/, /:\n/g; s/=.*/:/ }' \ -e '/^[^=]*$/{ s/, /\n/g }')) declare -a flags_o flags_l - flags_o=($(printf '%s\n' "${widff_flags[@]}"|sed -n 's/^-[^-]//p')) - flags_l=($(printf '%s\n' "${widff_flags[@]}"|sed -n 's/^--//p')) + flags_o=($(printf -- '%s\n' "${wdiff_flags[@]}"|sed -rn 's/^-([^-])/\1/p')) + flags_l=($(printf -- '%s\n' "${wdiff_flags[@]}"|sed -n 's/^--//p')) declare o l IFS='' o="${flags_o[*]}" @@ -36,15 +36,15 @@ wdiff_getopt() { esac done if [[ $# -lt 2 ]]; then - printf '%s: %s\n' "$0" "$(gettext 'missing file arguments')" >&2 + printf -- '%s: %s\n' "$0" "$(gettext 'missing file arguments')" >&2 return 1 elif [[ $# -gt 2 ]]; then - printf '%s: %s\n' "$0" "$(gettext 'too many file arguments')" >&2 + printf -- '%s: %s\n' "$0" "$(gettext 'too many file arguments')" >&2 return 1 fi # Return the result - printf '%s' "$args" + printf -- '%s' "$args" } main() { -- cgit v1.2.3