From 1ff77f1a97dd61845a39dc6354f5b89748ef2915 Mon Sep 17 00:00:00 2001
From: "Deven T. Corzine" <deven@ties.org>
Date: Sun, 2 Mar 2025 03:54:50 -0500
Subject: [PATCH 2/2] doc: Update texinfo documentation to use -print0 in more
 examples.

Model best practices by using -print0 in more "find ... | xargs" examples.

* doc/find.texi: Use -print0 in more examples.
---
 doc/find.texi | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/doc/find.texi b/doc/find.texi
index 5e835736..a27a3cad 100644
--- a/doc/find.texi
+++ b/doc/find.texi
@@ -2540,7 +2540,7 @@ daily from @code{cron}, then any user can remove any file on the
 system:
 
 @example
-find / -name '#*' -atime +7 -print | xargs rm
+find / -name '#*' -atime +7 -print0 | xargs -0 rm
 @end example
 
 For example, you could do something like this:
@@ -2567,7 +2567,7 @@ eg$ mkdir u u/joeuser u/joeuser/.plan'
 eg$ echo > u/joeuser/.plan'
 /#foo'
 eg$ cd ..
-eg$ find . -name '#*' -print | xargs echo
+eg$ find . -name '#*' -print0 | xargs -0 echo
 ./# ./# /u/joeuser/.plan /#foo
 @end example
 
@@ -2781,7 +2781,7 @@ enough work that it takes significant time to run, even on a single
 image.  You could run:
 
 @example
-find originals -name '*.jpg' | xargs -L 1 makeallsizes
+find originals -name '*.jpg' -print0 | xargs -0 -L 1 makeallsizes
 @end example
 
 This will run @code{makeallsizes @var{filename}} once for each @code{.jpg}
@@ -2790,7 +2790,7 @@ two central processors, this script will only keep one of them busy.
 Instead, you could probably finish in about half the time by running:
 
 @example
-find originals -name '*.jpg' | xargs -L 1 -P 2 makeallsizes
+find originals -name '*.jpg' -print0 | xargs -0 -L 1 -P 2 makeallsizes
 @end example
 
 @code{xargs} will run the first two commands in parallel, and then
@@ -3050,7 +3050,7 @@ running @code{file} on files that are not regular files or are not
 executable.
 
 @example
-find /usr/local -type f -perm /a=x | xargs file |
+find /usr/local -type f -perm /a=x -print0 | xargs -0 file |
   grep 'not stripped' | cut -d: -f1
 @end example
 
@@ -4571,7 +4571,7 @@ directories lacking either user or group write permission (or both),
 and fix their permissions:
 
 @example
-find . -type d -not -perm -ug=w | xargs chmod ug+w
+find . -type d -not -perm -ug=w -print0 | xargs -0 chmod ug+w
 @end example
 
 @noindent
@@ -4696,7 +4696,7 @@ from its standard input and builds them into command lines.  We can
 use it like this:
 
 @smallexample
-find /var/tmp/stuff -mtime +90 -print | xargs /bin/rm
+find /var/tmp/stuff -mtime +90 -print0 | xargs -0 /bin/rm
 @end smallexample
 
 For example if the files found by @code{find} are
@@ -5586,7 +5586,7 @@ actions are just as insecure as @samp{-exec}.
 In fact, since the construction
 
 @example
-find @dots{}  -print | xargs @enddots{}
+find @dots{} -print | xargs @enddots{}
 @end example
 
 does not cope correctly with newlines or other ``white space'' in
-- 
2.34.1

