git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv2 1/3] git-sh-setup: introduce say() for quiet options

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 15, 2009, 04:23 UTC
Message-ID
<7vab4ap1lf.fsf@alter.siamese.dyndns.org>
In-Reply-To
<18071eea0906141621t676a965aqc3056b481b8e8796@mail.gmail.com>
Thomas Adam <thomas.adam22@gmail.com> writes:
Show 25 quoted lines
> 2009/6/15 Stephen Boyd <bebarino@gmail.com>:
>> Scripts should use say() when they want to echo to stdout. Setting
>> GIT_QUIET will mute say(), allowing scripts to easily implement a quiet
>> option.
>>
>> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
>> ---
>>  git-sh-setup.sh |    7 +++++++
>>  1 files changed, 7 insertions(+), 0 deletions(-)
>>
>> diff --git a/git-sh-setup.sh b/git-sh-setup.sh
>> index 80acb7d..f88184e 100755
>> --- a/git-sh-setup.sh
>> +++ b/git-sh-setup.sh
>> @@ -44,6 +44,13 @@ die() {
>>        exit 1
>>  }
>>
>> +say () {
>> +       if test -z "$GIT_QUIET"
>> +       then
>> +               echo "$@"
>
> Except that where you've then replaced various calls with say() they
> were originally using printf.

The only difference I found in these three patch series is this hunk on git-am.sh in [PATCHv2 3/3]:

    @@ -498,7 +505,7 @@ do
                    stop_here $this
            fi
    -       printf 'Applying: %s\n' "$FIRSTLINE"
    +       say "Applying: $FIRSTLINE"
            case "$resolved" in
            '')

This was made from echo to printf with 4b7cc26 (git-am: use printf instead of echo on user-supplied strings, 2007-05-25), with reason:

    Under some implementations of echo (such as that provided by
    dash), backslash escapes are recognized without any other
    options. This means that echo-ing user-supplied strings may
    cause any backslash sequences in them to be converted. Using
    printf resolves the ambiguity.
    
    This bug can be seen when using git-am to apply a patch
    whose subject contains the character sequence "\n"; the
    characters are converted to a literal newline. Noticed by
    Szekeres Istvan.
To make the conversion of the above hunk correct, say() must use
	printf "%s" "$*"

Needless to say, all the conversions from "echo" to "say" in the patch series need to be verified.

Previous: Thomas AdamNext: Stephen Boyd
Message 15 of 18 in “teach am and rebase -q/--quiet”
  1. 0/2 teach am and rebase -q/--quietStephen Boyd, Jun 13, 2009
  2. 1/2 am: teach quiet optionStephen Boyd, Jun 13, 2009
  3. 2/2 rebase: teach quiet optionStephen Boyd, Jun 13, 2009
  4. Junio C HamanoJun 13, 2009
  5. Stephen BoydJun 14, 2009
  6. Sverre RabbelierJun 14, 2009
  7. Junio C HamanoJun 13, 2009
  8. Stephen BoydJun 14, 2009
  9. Junio C HamanoJun 14, 2009
  10. 0/3 Teach shell scripts to be quietStephen Boyd, Jun 14, 2009
  11. 1/3 git-sh-setup: introduce say() for quiet optionsStephen Boyd, Jun 14, 2009
  12. 2/3 submodule, repack: migrate to git-sh-setup's say()Stephen Boyd, Jun 14, 2009
  13. 3/3 am, rebase: teach quiet optionStephen Boyd, Jun 14, 2009
  14. Thomas AdamJun 14, 2009
  15. Junio C HamanoJun 15, 2009
  16. Stephen BoydJun 15, 2009
  17. Johannes SixtJun 15, 2009
  18. Stephen BoydJun 15, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.