flex icon indicating copy to clipboard operation
flex copied to clipboard

build: Fix unportable sed expression in mkskel.sh

Open Explorer09 opened this issue 6 years ago • 6 comments

'\r' in sed is not portable, at least to BSD sed (and macOS). Replace it with embedded CR character in sed expression.

Fixes #294 (regression caused by #243)

@stek29 and @jannick0, I need you to test this one as I don't have a BSD sed to do so.

Explorer09 avatar Apr 24 '18 03:04 Explorer09

@Explorer09 That looks good for LF and CRLF files where sed from cygwin32 and msys2 is called. I cannot say anything about CR files, since I am on Windows, but I am curious if it works on macOS, as well.

jannick0 avatar Apr 24 '18 18:04 jannick0

@jannick0 I'm not caring for CR-only files yet. Since Mac OS Classic ports of sed (if any) would need to treat CR as pattern space terminators anyway and is beyond what our sed expression can workaround already. My idea was to accept both CR+LF and LF, but output in the OS-native line termination scheme (or whatever the sed was configured to output). Any complex line termination scheme (CR only, NEL ('\x85') or form feeds ('\f')) is beyond the scope of this patch.

Explorer09 avatar Apr 25 '18 01:04 Explorer09

Note: sed uses the pattern space concept instead of a line for processing. The reason is that sed allows joining multiple lines into one pattern space for processing together (with N command), or split a line into two spaces (P;D commands combination) for processing. The pattern space is more flexible than a line in terms of stream processing.

Explorer09 avatar Apr 25 '18 01:04 Explorer09

Sorry for long wait I confirm it works fine with Apple (BSD?) sed.

stek29 avatar Apr 27 '18 12:04 stek29

Thanks for the confirmation.

On Friday, 27 April 2018, 12:09 pm +0000, Viktor Oreshkin [email protected] wrote:

Sorry for long wait I confirm it works fine with Apple (BSD?) sed.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/westes/flex/pull/353#issuecomment-384951452

-- Will Estes [email protected]

westes avatar Apr 27 '18 12:04 westes

Resolve #539

wendajiang avatar Aug 10 '22 07:08 wendajiang

This got handled by other means.

westes avatar Mar 29 '24 14:03 westes