Re: What's cooking in git.git (Jan 2021, #02; Fri, 8)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Aguilar <davvid@xxxxxxxxx> writes:

> Fun times in sed portability land.  After a bit of experimentation,
> this is what I've managed to whip up:
>
> cr=$(printf '\x0d')
> sed -e "/^<<<<<<< /,/^=======$cr\{0,1\}$/d" -e '/^>>>>>>> /d' tiger
>
> - Instead of \r use printf to capture CR into a string so that we can
> embed the literal using $cr.
> - DQ "..." instead of SQ '...' to allow $cr to be substituted in the string.
> - Instead of \? use \{0,1\} which seems to work on both macOS and Linux.

Ah, all the fun with avoiding GNU-ism in scripts; thanks for
figuring it out.

I am perfectly fine with the above, but I also am OK with Perl
script.  We may even be able to generate three output files in a
single pass by passing their filenames and open them for writing in
the script.

> That seems to work and the tests now pass.
> If not sed, is there perhaps a perl equivalent for these multi-line
> delete-from-X-until-Y expressions that might provide better
> portability?

> I'll start putting together a patch shortly as this seems to work in
> practice.  Let me know if y'all have any sugs or if there are any
> portability pitfalls I'm not considering.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux