Re: encountered a sed POSIX gotcha (GNU vs. BSD)

"Daniel Goldman [email protected] [sed-users]" <[email protected]> Sun, 6 May 2018 16:12:03 -0700
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
"From the same POSIX spec" - Thank you for pointing out the ; text in 
the POSIX specification. I searched for ';' and did not see anything 
relevant. Did not think to search for 'semicolon'... And thanks again 
for pointing out the gotcha, and about POSIXLY_CORRECT. Daniel

On 5/6/2018 3:35 PM, Tim Chase [email protected] [sed-users] wrote:
> On 2018-05-06 13:32, Daniel Goldman [email protected] [sed-users]
> wrote:
>> Can anyone else find ';' mentioned in POSIX documentation? I
>> looked, did not seem any mention of using ';' to separate commands.
>
>  From the same POSIX spec I linked to, right above the previous text I
> quoted I found this:
>
> "Editing commands other than {...}, a, b, c, i, r, t, w, :, and # can
> be followed by a <semicolon>, optional <blank> characters, and
> another editing command."
>
>> To me, having ';' capability seems pretty essential. If POSIX does
>> not mention ';' between commands, it would seem POSIX is maybe
>> obsolete, in need of updating.
>
> So the ";" separating commands *is* part of POSIX.
>
>> If I was designing from scratch, I think gnu sed probably has it
>> "right" here, because sed should be able to see that the
>> right-brace is terminating the { } group. How does the ';' help
>> figure that out? To me ';}' seems OK (like an odd emoticon!), but
>> just '}' seems better.
>
> I agree with the sentiment here -- it's how I found it because I'm
> usually in a GNU environment and I usually omit it, but got stung
> testing a command on OpenBSD that had worked on Debian.
>
>> I tend to take gnu sed as the "truth". It seems to me the best /
>> most functional version. But maybe I am wrong. Which takes
>> precedence: gnu sed behavior (my vote) or POSIX specification?
>
> I think this is why I lean towards the GNU convention of a
> POSIXLY_CORRECT environment variable.  For those cases where POSIX
> compliance matters, you can get it; yet without POSIXLY_CORRECT in
> the environment, it shouldn't break existing non-POSIX scripts.  And
> if you claim you are POSIXLY_CORRECT via your environment and aren't
> compliant, it should balk at such violations and error out.
>
> -tim
>
>
>
>
>
>
>
> ------------------------------------
> Posted by: Tim Chase <[email protected]>
> ------------------------------------
>


------------------------------------

------------------------------------

-- 

------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/sed-users/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/sed-users/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/