aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2012-01-27 14:40:24 +0000
committerWerner Koch <[email protected]>2012-01-27 14:40:24 +0000
commit2871422d9a889cb632f59efda4d9cd170fc9fca7 (patch)
treed1f3577faabe289d2cacc30314abcba0a993efe2
parentReturn GPG_ERR_CARD_NOT_PRESENT when pinentry-mode=loopback. (diff)
downloadgnupg-2871422d9a889cb632f59efda4d9cd170fc9fca7.tar.gz
gnupg-2871422d9a889cb632f59efda4d9cd170fc9fca7.zip
gpg-connect-tool: Take the string "true" as a true condition.
* tools/gpg-connect-agent.c (main): Handle strings "true" and "yes" in conditions as expected.
-rw-r--r--doc/tools.texi17
-rw-r--r--tools/gpg-connect-agent.c9
2 files changed, 20 insertions, 6 deletions
diff --git a/doc/tools.texi b/doc/tools.texi
index 5e9a02487..be1233b16 100644
--- a/doc/tools.texi
+++ b/doc/tools.texi
@@ -1407,11 +1407,11 @@ input lines which makes scripts easier to read.
@item /while @var{condition}
@itemx /end
-These commands provide a way for executing loops. All lines between the
-@code{while} and the corresponding @code{end} are executed as long as
-the evaluation of @var{condition} yields a non-zero value. The
-evaluation is done by passing @var{condition} to the @code{strtol}
-function. Example:
+These commands provide a way for executing loops. All lines between
+the @code{while} and the corresponding @code{end} are executed as long
+as the evaluation of @var{condition} yields a non-zero value or is the
+string @code{true} or @code{yes}. The evaluation is done by passing
+@var{condition} to the @code{strtol} function. Example:
@smallexample
/subst
@@ -1422,6 +1422,13 @@ function. Example:
/end
@end smallexample
+@item /if @var{condition}
+@itemx /end
+These commands provide a way for conditional execution. All lines between
+the @code{if} and the corresponding @code{end} are executed only if
+the evaluation of @var{condition} yields a non-zero value or is the
+string @code{true} or @code{yes}. The evaluation is done by passing
+@var{condition} to the @code{strtol} function.
@item /run @var{file}
Run commands from @var{file}.
diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c
index 117f3380c..7472728c6 100644
--- a/tools/gpg-connect-agent.c
+++ b/tools/gpg-connect-agent.c
@@ -1747,7 +1747,14 @@ main (int argc, char **argv)
}
tmpline = substitute_line (tmpcond);
value = tmpline? tmpline : tmpcond;
- condition = strtol (value, NULL, 0);
+ /* "true" or "yes" are commonly used to mean TRUE;
+ all other strings will evaluate to FALSE due to
+ the strtoul. */
+ if (!ascii_strcasecmp (value, "true")
+ || !ascii_strcasecmp (value, "yes"))
+ condition = 1;
+ else
+ condition = strtol (value, NULL, 0);
xfree (tmpline);
xfree (tmpcond);