A NOTE has been added to this issue. ====================================================================== https://austingroupbugs.net/view.php?id=1872 ====================================================================== Reported By: steffen Assigned To: ====================================================================== Project: 1003.1(2024)/Issue8 Issue ID: 1872 Category: Shell and Utilities Type: Clarification Requested Severity: Editorial Priority: normal Status: Resolved Name: steffen Organization: User Reference: Section: find Page Number: 2946 Line Number: 98444 ff. Interp Status: --- Final Accepted Text: https://austingroupbugs.net/view.php?id=1872#c6956 Resolution: Accepted As Marked Fixed in Version: ====================================================================== Date Submitted: 2024-11-07 21:34 UTC Last Modified: 2024-11-17 08:17 UTC ====================================================================== Summary: find: clarify "less safe" statement ======================================================================
---------------------------------------------------------------------- (0006960) stephane (reporter) - 2024-11-17 08:17 https://austingroupbugs.net/view.php?id=1872#c6960 ---------------------------------------------------------------------- Re: https://austingroupbugs.net/view.php?id=1872#c6959 AFAIK, in POSIX terminology, "delimiter" is closer to "terminator" than "separator". IFS is the Internal Field Delimiter which with IFS=: splits "a::b:" into "a", "" and "b" (and not an extra empty element), newline is the line delimiter, a -d was added to "read" (not an invention, that comes from ksh93 and supported by several other shells; and read returns failure if the record is not delimited) in the same resolution than introduced xargs -r -0 (again options already supported for decades by several implementations). Note that I'm as much a POSIX developer as you are and not part of the "group" in charge of the specification. I'm just giving my opinion as a long time shell user and contributor to news://comp.unix.shell, now https://unix.stackexchange.com. I was mentioning xargs -d as it is already implemented in GNU xargs, and -D as a potential avenue implementations (not POSIX at this point) could fix that issue without breaking backward compatibility if they deemed it was an issue worth fixing. IMO, it's a bad idea to change the behaviour of xargs -0 now as it's been working the way it does now (accept and process a trailing non-delimited record) for over 30 years and been relied upon as already mentioned. It's also futile to think that would fix the issue. To fully fix that "issue", we'd need all tools that process NL or NUL delimited records to discard/reject non-delimited records. For instance, it's common to use tr '\0\n' '\n\0' to convert NUL-delimited records into newline delimited ones so that tools that work on lines (and can cope with NULs in those lines) can be used to process it. In: find /src -name '*.d' -type d -print0 | tr '\0\n' '\n\0' | rev | cut -d/ -f1 | rev | sort -u | tr '\0\n' '\n\0' | (cd /dst && xargs -r0 mkdir -p --) No point in xargs ignoring/discarding a non-delimited record if none of rev, cut, sort process non-delimited lines. And the whole point of xargs as opposed to find -exec ... {} + is that you can insert those processing tools in the middle. Issue History Date Modified Username Field Change ====================================================================== 2024-11-07 21:34 steffen New Issue 2024-11-07 21:34 steffen Name => steffen 2024-11-07 21:34 steffen Section => find 2024-11-07 21:34 steffen Page Number => 2946 2024-11-07 21:34 steffen Line Number => 98444 ff. 2024-11-07 21:38 steffen Note Added: 0006951 2024-11-08 01:40 steffen Note Added: 0006952 2024-11-08 01:42 steffen Note Edited: 0006952 2024-11-08 08:31 stephane Note Added: 0006953 2024-11-12 09:48 geoffclare Note Added: 0006954 2024-11-13 18:19 steffen Note Edited: 0006952 2024-11-14 17:03 geoffclare Note Added: 0006956 2024-11-14 17:04 geoffclare Interp Status => --- 2024-11-14 17:04 geoffclare Final Accepted Text => https://austingroupbugs.net/view.php?id=1872#c6956 2024-11-14 17:04 geoffclare Status New => Resolved 2024-11-14 17:04 geoffclare Resolution Open => Accepted As Marked 2024-11-14 17:05 geoffclare Tag Attached: tc1-2024 2024-11-14 17:08 geoffclare Note Edited: 0006956 2024-11-16 08:54 stephane Note Added: 0006957 2024-11-16 19:42 steffen Note Added: 0006958 2024-11-17 03:03 philip-guentherNote Added: 0006959 2024-11-17 08:17 stephane Note Added: 0006960 ======================================================================
