From: Phillip Wood Date: Wed, 22 Apr 2026 14:12:39 GMT Subject: Re: [PATCH v2] generate-configlist: collapse depfile for older Ninja Message-ID: In-Reply-To: <0557838b-214d-4e8f-9cbd-bc342563e9ba@gmail.com> On 22/04/2026 14:45, Phillip Wood wrote: > >     sed -e "s/second/second \\\n foo/" patch1 >patchnl && Of course the extra backslashes would supress any special meaning of '\n' so that's not a good example. However the freebsd man page [1] says The escape sequence \n matches a newline character embedded in the pattern space. You cannot, however, use a literal newline character in an address or in the substitute command. Thanks Phillip [1] https://man.freebsd.org/cgi/man.cgi?query=sed&apropos=0&sektion=0&manpath=FreeBSD+16.0-CURRENT&format=html > > However if I add "cat patchnl" it shows the subject line is > >     Subject: [PATCH] second \n foo > > so sed has inserted "\n" rather than a newline. Indeed looking at the > commit message for that test it is testing a fix that c escapes are > printed verbatim introduced by 4b7cc26a74 (git-am: use printf instead of > echo on user-supplied strings, 2007-05-25). > > I've not tested it but I think > >     sed 's/ $/\ > /' > > will insert a newline. Alternatively we could do > >     printf '%s' "$QUOTED_OUTPUT: " >     printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ >              "$SOURCE_DIR"/Documentation/config/*.adoc | >         sed -e 's/[# ]/\\&/g' | >         tr '\n' ' ' >     printf '\n' > > That leaves a trailing space at the end of the line but I don't think > that should matter. > > As I recall, the depfiles created by gcc have all the dependencies on a > single line so this should be widely supported and I agree with Patrick > that we should do this unconditionally. > > Thanks > > Phillip > > [1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html > >>           printf '%s:\n' "$SOURCE_DIR"/Documentation/*config.adoc \ >>               "$SOURCE_DIR"/Documentation/config/*.adoc | >>               sed -e 's/[# ]/\\&/g' >> >> --- >> base-commit: 94f057755b7941b321fd11fec1b2e3ca5313a4e0 >> change-id: 20260421-toon-fix-almalinux8-102de9138294 >> >> >