I've seen several command-line applications, including OpenSSH, which require the user to type the entire word yes
or no
at a yes/no prompt, rejecting single-letter inputs like y
. Here's an example:
The authenticity of host 'localhost (127.0.0.1)' can't be established.
RSA key fingerprint is 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': y
Please type 'yes' or 'no': yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Is this ever a good idea? If so, when should this be done? If not, what technical reasons might there be for a yes/no prompt to be implemented this way?
Update
The source code for the confirmation prompt is as follows:
/* defaults to 'no' */
static int
confirm(const char *prompt)
{
const char *msg, *again = "Please type 'yes' or 'no': ";
char *p;
int ret = -1;
if (options.batch_mode)
return 0;
for (msg = prompt;;msg = again) {
p = read_passphrase(msg, RP_ECHO);
if (p == NULL ||
(p[0] == '\0') || (p[0] == '\n') ||
strncasecmp(p, "no", 2) == 0)
ret = 0;
if (p && strncasecmp(p, "yes", 3) == 0)
ret = 1;
if (p)
xfree(p);
if (ret != -1)
return ret;
}
}
I suspect this is intended to protect against buffer overflows at the prompt, which is especially important for a security-sensitive application like OpenSSH. Neither y
nor n
is accepted as valid input, although a blank input is treated as "no". However, is this an appropriate decision from a UX standpoint?