aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/find
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2005-04-02 07:44:12 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2005-04-02 07:44:12 +0000
commitef6c77648aa5959b4eb0f7565294e87c014172c3 (patch)
tree778202800cf904dfbf2b6df563af45cdbf16d390 /usr.bin/find
parent8550a8f5874c23ce858fde76dd69d5d21e7dd98a (diff)
downloadsrc-ef6c77648aa5959b4eb0f7565294e87c014172c3.tar.gz
src-ef6c77648aa5959b4eb0f7565294e87c014172c3.zip
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.
Notes
Notes: svn path=/head/; revision=144526
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/find.118
-rw-r--r--usr.bin/find/misc.c24
2 files changed, 24 insertions, 18 deletions
diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1
index e8a640cfa170..269cf9f76462 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 fe11e04df0c5..15329064cf44 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);
}