Page MenuHomeFreeBSD

git-arc: Use printf instead of echo
AbandonedPublic

Authored by 0mp on Oct 24 2024, 8:42 AM.
Tags
None
Referenced Files
F105541379: D47274.diff
Tue, Dec 17, 10:46 AM
Unknown Object (File)
Nov 10 2024, 12:12 AM
Unknown Object (File)
Oct 29 2024, 3:34 AM
Unknown Object (File)
Oct 28 2024, 10:32 AM
Unknown Object (File)
Oct 28 2024, 10:31 AM
Unknown Object (File)
Oct 28 2024, 10:10 AM
Unknown Object (File)
Oct 28 2024, 1:43 AM
Subscribers

Details

Summary

Some shell implementations other than FreeBSD's sh(1) do not handle
handle passing complex strings to echo. For example,
git arc create HEAD works with macOS' sh(1) but
git arc patch -c D12345 would error out with:

jq: parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 27, column 57

Fix that by using printf consistently across git-arc(1).

MFC after: 2 weeks

Test Plan

I've been using printfs in git-arc for some time now when I use git-arc(1) on macOS.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 60181
Build 57065: arc lint + arc unit

Event Timeline

0mp requested review of this revision.Oct 24 2024, 8:42 AM
0mp added reviewers: bnovkov, christos, markj.
This revision is now accepted and ready to land.Oct 24 2024, 10:42 AM
des requested changes to this revision.Oct 24 2024, 11:21 AM
des added a subscriber: des.

revert everything except the three places I commented

tools/tools/git/git-arc.sh
331

no -n needed here

447

keep this

464
This revision now requires changes to proceed.Oct 24 2024, 11:21 AM

Thank you for making this tool more portable. This is a cousin commit of D46781 and D46767. I agree, echo (without -n is portable) and IMO, more readable than printf, because there is no need to add a new line at the end. The issue is only with echo -n.

In D47274#1077940, @jlduran_gmail.com wrote:

Thank you for making this tool more portable. This is a cousin commit of D46781 and D46767. I agree, echo (without -n is portable) and IMO, more readable than printf, because there is no need to add a new line at the end. The issue is only with echo -n.

Amazing work! I've not seen those patches earlier! I'll review and commit them.

I'm closing this revision as I landed @jlduran_gmail.com's patches instead: