Add GNU-style `-print0' primary. This exists so that one can safely
do `find some-nasty-expression -print0 | perl -n0e unlink' and have all the files actuallly get deleted. (Using `xargs' and `rm' is not safe.)
This commit is contained in:
parent
2b50c84ac1
commit
7cd23434fe
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8389
@ -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 *));
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -793,6 +793,30 @@ c_print()
|
||||
return (palloc(N_PRINT, f_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 --
|
||||
*
|
||||
|
@ -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 },
|
||||
|
Loading…
Reference in New Issue
Block a user