Page MenuHome GnuPG

--yes sometimes doesn't work without --batch, but this is not well-documented
Open, NormalPublic

Description

over in https://bugs.debian.org/833481, Adam Borowski notes that --yes often
does not work unless --batch is also supplied.

Looking at the source, i see that --yes is mapped to oAnswerYes, which is in
turn mapped to opt.answer_yes.

0 dkg@alice:~/src/gnupg$ git grep answer_yes
g10/ChangeLog-2011: cpr_get_answer_is_yes,cpr_get_answer_yes_no_quit): Modified
to work
g10/ChangeLog-2011: * status.c (cpr_get_answer_yes_no_quit): New.
g10/cpr.c:cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt )
g10/delkey.c: else if (opt.batch && opt.answer_yes)
g10/delkey.c: opt.answer_yes);
g10/gpg.c: case oAnswerYes: opt.answer_yes = 1; break;
g10/keyedit.c: if (opt.batch && opt.answer_yes)
g10/keyedit.c: okay = cpr_get_answer_yes_no_quit
g10/keyedit.c: okay = cpr_get_answer_yes_no_quit
g10/keyedit.c: okay = cpr_get_answer_yes_no_quit
g10/keygen.c: use_tty = (!opt.batch && !opt.answer_yes
g10/keygen.c: if (opt.answer_yes)
g10/main.h:int cpr_get_answer_yes_no_quit( const char *keyword, const char
*prompt );
g10/openfile.c: if (opt.answer_yes)
g10/options.h: int answer_yes; /* answer yes on most questions */
g10/photoid.c: switch(cpr_get_answer_yes_no_quit("photoid.jpeg.okay",
g10/trustdb.c: if (opt.batch && !opt.answer_yes)
sm/gpgsm.c: case oAnswerYes: opt.answer_yes = 1; break;
sm/gpgsm.h: int answer_yes; /* assume yes on most questions */
0 dkg@alice:~/src/gnupg$

It appears two places don't require opt.batch:

  • openfile.c
  • keygen.c

and three do:

  • trustdb.c
  • delkey.c
  • keyedit.c

If there's a pattern to this, it's not clear what it is. Could the pattern be
made simpler (e.g. --yes only works with --batch everywhere; or --yes works
regardless of --batch)? And could the behavior be explained clearly in the
usual place where people look for documentation (e.g. doc/gpg.texi)?

Details

Version
2.1.14

Event Timeline

dkg added projects: gnupg, Bug Report.
dkg added a subscriber: dkg.

Well, the man page states

  --yes  Assume "yes" on most questions.

Note the "most" ;-)

I agree that there is no clear pattern. I tried to make use of --yes in way to
minimizes surprising loss of data. Can certainly be improved.