From ec3628d8dbd4d112033b4ca79c296ad570222a22 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Thu, 20 Sep 2012 00:59:16 +0100 Subject: [PATCH] keyfunc.sh.in: Make sure we can match the `0' string. Organization: Straylight/Edgeware From: Mark Wooding The expr(1) tool exits with status 1 if its output is zero. The `:' operator evaluates to the substring matched by the outermost parentheses in the pattern, if there are any. Therefore, matching `0' against the `R_NUMERIC' pattern always appears to fail. Fix this and similar problems by adding extra parens around the entire pattern, including the leading sentinel `Q'. --- keyfunc.sh.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/keyfunc.sh.in b/keyfunc.sh.in index 98354d1..31843bf 100644 --- a/keyfunc.sh.in +++ b/keyfunc.sh.in @@ -154,8 +154,14 @@ check () { validp=t case "$thing" in - *"$nl"*) validp=nil ;; - *) if ! expr >/dev/null "Q$thing" : "Q$ckpat\$"; then validp=nil; fi ;; + *"$nl"*) + validp=nil + ;; + *) + if ! expr >/dev/null "Q$thing" : "\(Q$ckpat\)\$"; then + validp=nil + fi + ;; esac case $validp in nil) echo >&2 "$quis: bad $ckwhat \`$thing'"; exit 1 ;; -- [mdw]