sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit b1c6185a40f7a40381ab78b97f6715b09f84a9e4
parent 9d9afe00fb2afbc2b6bfd364f04f108adb917d43
Author: Tavian Barnes <tavianator@tavianator.com>
Date:   Sat, 22 Feb 2025 13:14:51 +0100

find: Implement -print0

Diffstat:
Mfind.c | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/find.c b/find.c @@ -133,6 +133,7 @@ static int pri_mtime (struct arg *arg); static int pri_exec (struct arg *arg); static int pri_ok (struct arg *arg); static int pri_print (struct arg *arg); +static int pri_print0 (struct arg *arg); static int pri_newer (struct arg *arg); static int pri_depth (struct arg *arg); @@ -191,6 +192,7 @@ static struct pri_info primaries[] = { { "-exec" , pri_exec , get_exec_arg , free_exec_arg, 1 }, { "-ok" , pri_ok , get_ok_arg , free_ok_arg , 1 }, { "-print" , pri_print , get_print_arg, NULL , 0 }, + { "-print0" , pri_print0 , get_print_arg, NULL , 0 }, { "-newer" , pri_newer , get_newer_arg, NULL , 1 }, { "-depth" , pri_depth , get_depth_arg, NULL , 0 }, @@ -474,6 +476,14 @@ pri_print(struct arg *arg) return 1; } +static int +pri_print0(struct arg *arg) +{ + if (fwrite(arg->path, strlen(arg->path) + 1, 1, stdout) != 1) + eprintf("fwrite failed:"); + return 1; +} + /* FIXME: ignoring nanoseconds */ static int pri_newer(struct arg *arg)