From 3a8b8f05cd5c0b2d6f806378d6b9702de46bb60b Mon Sep 17 00:00:00 2001 From: tjr Date: Sat, 2 Apr 2005 07:44:12 +0000 Subject: 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. --- usr.bin/find/find.1 | 18 +++++++++++++++--- usr.bin/find/misc.c | 24 +++++++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) (limited to 'usr.bin/find') diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index e8a640c..269cf9f 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -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 diff --git a/usr.bin/find/misc.c b/usr.bin/find/misc.c index fe11e04df..1532906 100644 --- a/usr.bin/find/misc.c +++ b/usr.bin/find/misc.c @@ -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); } -- cgit v1.1