Use rpmatch() instead of checking for responses that begin with 'y'
in queryuser(). This allows users to respond to -ok and -okdir prompts with any affirmative reply defined by their current locale.
This commit is contained in:
parent
8550a8f587
commit
ef6c77648a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=144526
@ -35,7 +35,7 @@
|
||||
.\" @(#)find.1 8.7 (Berkeley) 5/9/95
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd July 29, 2004
|
||||
.Dd April 2, 2005
|
||||
.Dt FIND 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -535,8 +535,11 @@ requests user affirmation for the execution of the
|
||||
.Ar utility
|
||||
by printing
|
||||
a message to the terminal and reading a response.
|
||||
If the response is other than
|
||||
.Dq Li y
|
||||
.No If the response is not affirmative ( Ns
|
||||
.Ql y
|
||||
in the
|
||||
.Dq Li POSIX
|
||||
locale),
|
||||
the command is not executed and the
|
||||
value of the
|
||||
.Ic -ok
|
||||
@ -742,6 +745,15 @@ All operands and primaries must be separate arguments to
|
||||
Primaries which themselves take arguments expect each argument
|
||||
to be a separate argument to
|
||||
.Nm .
|
||||
.Sh ENVIRONMENT
|
||||
The
|
||||
.Ev LANG , LC_ALL , LC_COLLATE , LC_CTYPE , LC_MESSAGES
|
||||
and
|
||||
.Ev LC_TIME
|
||||
environment variables affect the execution of the
|
||||
.Nm
|
||||
utility as described in
|
||||
.Xr environ 7 .
|
||||
.Sh EXAMPLES
|
||||
The following examples are shown as given to the shell:
|
||||
.Bl -tag -width indent
|
||||
|
@ -83,12 +83,13 @@ brace_subst(char *orig, char **store, char *path, int len)
|
||||
/*
|
||||
* queryuser --
|
||||
* print a message to standard error and then read input from standard
|
||||
* input. If the input is 'y' then 1 is returned.
|
||||
* input. If the input is an affirmative response (according to the
|
||||
* current locale) then 1 is returned.
|
||||
*/
|
||||
int
|
||||
queryuser(char *argv[])
|
||||
{
|
||||
int ch, first, nl;
|
||||
char *p, resp[256];
|
||||
|
||||
(void)fprintf(stderr, "\"%s", *argv);
|
||||
while (*++argv)
|
||||
@ -96,20 +97,13 @@ queryuser(char *argv[])
|
||||
(void)fprintf(stderr, "\"? ");
|
||||
(void)fflush(stderr);
|
||||
|
||||
first = ch = getchar();
|
||||
for (nl = 0;;) {
|
||||
if (ch == '\n') {
|
||||
nl = 1;
|
||||
break;
|
||||
}
|
||||
if (ch == EOF)
|
||||
break;
|
||||
ch = getchar();
|
||||
}
|
||||
|
||||
if (!nl) {
|
||||
if (fgets(resp, sizeof(resp), stdin) == NULL)
|
||||
*resp = '\0';
|
||||
if ((p = strchr(resp, '\n')) != NULL)
|
||||
*p = '\0';
|
||||
else {
|
||||
(void)fprintf(stderr, "\n");
|
||||
(void)fflush(stderr);
|
||||
}
|
||||
return (first == 'y');
|
||||
return (rpmatch(resp) == 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user