summaryrefslogtreecommitdiff
path: root/usr.bin/find
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>1995-05-09 19:02:06 +0000
committerGarrett Wollman <wollman@FreeBSD.org>1995-05-09 19:02:06 +0000
commit7cd23434fe4cb60386f172416370876c6def6408 (patch)
tree3824a53da4fe2907a82c2e56c64ecc75e069be0b /usr.bin/find
parent2b50c84ac1cef8d31224642d605c8744bcf9ebac (diff)
Notes
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/extern.h1
-rw-r--r--usr.bin/find/find.116
-rw-r--r--usr.bin/find/find.h1
-rw-r--r--usr.bin/find/function.c24
-rw-r--r--usr.bin/find/option.c1
5 files changed, 39 insertions, 4 deletions
diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h
index 3db2d5fa549a..c9aba6f994ee 100644
--- a/usr.bin/find/extern.h
+++ b/usr.bin/find/extern.h
@@ -64,6 +64,7 @@ PLAN *c_nouser __P((void));
PLAN *c_path __P((char *));
PLAN *c_perm __P((char *));
PLAN *c_print __P((void));
+PLAN *c_print0 __P((void));
PLAN *c_prune __P((void));
PLAN *c_size __P((char *));
PLAN *c_type __P((char *));
diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1
index 6523bbaf45cb..b92f95ccec0b 100644
--- a/usr.bin/find/find.1
+++ b/usr.bin/find/find.1
@@ -265,12 +265,19 @@ Note, the first character of a symbolic mode may not be a dash (``\-'').
.It Ic -print
This primary always evaluates to true.
It prints the pathname of the current file to standard output.
-The expression is appended to the user specified expression if neither
+The expression is appended to the user specified expression if none of
.Ic -exec ,
-.Ic -ls
+.Ic -ls ,
+.Ic -print0 ,
or
.Ic \&-ok
-is specified.
+are specified.
+.It Ic -print0
+This primary always evaluates to true.
+It prints the pathname of the current file to standard output, followed by a
+.Tn ASCII
+.Tn NUL
+character (character code 0).
.It Ic -prune
This primary always evaluates to true.
It causes
@@ -404,7 +411,8 @@ The
and
.Fl X
options and the
-.Ic -inum
+.Ic -inum ,
+.Ic -print0 ,
and
.Ic -ls
primaries are extensions to
diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h
index 4c4ffa54e9bd..8066d375245a 100644
--- a/usr.bin/find/find.h
+++ b/usr.bin/find/find.h
@@ -43,6 +43,7 @@ enum ntype {
N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MTIME, N_NAME, N_NEWER,
N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR, N_PATH,
N_PERM, N_PRINT, N_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV,
+ N_PRINT0
};
/* node definition */
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index f5376766322c..52e0f4378450 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -794,6 +794,30 @@ c_print()
}
/*
+ * -print0 functions --
+ *
+ * Always true, causes the current pathame to be written to
+ * standard output followed by a NUL character
+ */
+int
+f_print0(plan, entry)
+ PLAN *plan;
+ FTSENT *entry;
+{
+ fputs(entry->fts_path, stdout);
+ fputc('\0', stdout);
+ return (1);
+}
+
+PLAN *
+c_print0()
+{
+ isoutput = 1;
+
+ return (palloc(N_PRINT0, f_print0));
+}
+
+/*
* -prune functions --
*
* Prune a portion of the hierarchy.
diff --git a/usr.bin/find/option.c b/usr.bin/find/option.c
index 9b25ceed16d8..66596c381f54 100644
--- a/usr.bin/find/option.c
+++ b/usr.bin/find/option.c
@@ -79,6 +79,7 @@ static OPTION const options[] = {
{ "-path", N_PATH, c_path, O_ARGV },
{ "-perm", N_PERM, c_perm, O_ARGV },
{ "-print", N_PRINT, c_print, O_ZERO },
+ { "-print0", N_PRINT0, c_print0, O_ZERO },
{ "-prune", N_PRUNE, c_prune, O_ZERO },
{ "-size", N_SIZE, c_size, O_ARGV },
{ "-type", N_TYPE, c_type, O_ARGV },