Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Nov 2023 16:47:22 +0000
From:      Matthew Seaman <matthew@FreeBSD.org>
To:        dev-commits-src-all@freebsd.org
Subject:   Re: git: accfb4cc9346 - main - genoffset.sh: stop using a temporary file
Message-ID:  <514d9136-e169-47a2-9279-d9ef56697e9e@FreeBSD.org>
In-Reply-To: <CANCZdfr9G_jttwu8G85%2Bvcodf6SNnmt7WPhp8-M10vDrEroP2A@mail.gmail.com>
References:  <202311161507.3AGF7kgx070201@gitrepo.freebsd.org> <39921E4A-4C15-4D8F-BA9F-D0C53AD62CD1@freebsd.org> <CANCZdfr9G_jttwu8G85%2Bvcodf6SNnmt7WPhp8-M10vDrEroP2A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?514d9136-e169-47a2-9279-d9ef56697e9e>