Re: git: accfb4cc9346 - main - genoffset.sh: stop using a temporary file
- In reply to: Warner Losh : "Re: git: accfb4cc9346 - main - genoffset.sh: stop using a temporary file"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 16 Nov 2023 16:47:22 UTC
On 16/11/2023 16:23, Warner Losh wrote:
> On Thu, Nov 16, 2023 at 9:07 AM Jessica Clarke <jrtc27@freebsd.org> wrote:
>
>> On 16 Nov 2023, at 15:07, Jonathan T. Looney <jtl@FreeBSD.org> wrote:
>>> printf '\t"struct "#s"_lite field "#f" not at offset "#o)\n'
>>> - cat "$temp/asserts"
>>> + echo -e "${asserts}\c"
>>
>> This isn’t POSIX, and isn’t supported by macOS’s sh, so breaks the
>> build there. Please fix or revert promptly.
>>
>
> echo "${asserts}"
>
> is semantically the same for C. A stray newline doesn't matter in this
> context. It's not worth the effort to remove it.
>
> Sadly, echo -n doesn't work (it's not posix, and posix defines it
> specifically as implementation defined). `echo "fred\c"' works on macos,
> but not FreeBSD's shell echo built-in (but somehow does for /bin/echo).
> macos doesn't implement -e at all (it's also not posix). FreeBSD's shell
> echo build-in is not posix compliant. So, to be portable, just echo it, and
> cope with the extra newline.
>
> That's what I'd do :)
>
Why not just use printf(1) like in the preceeding line of code?
printf "%s" "${asserts}"
will avoid adding any extra newline characters to the output.
Matthew