summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-12-07 02:29:31 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-12-07 02:29:31 -0500
commit1c3ff57ac6086b3ff91d3c66de878a66e2493bc0 (patch)
treebc103f083b3ae066560ef70149d350682017fbc2
parent30c42d2c3f6a9ce65e85363601abd1e469a32a2f (diff)
chardiff: fix, escape possible printf flags
-rw-r--r--chardiff.sh10
1 files 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() {