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

Re: [PATCH v2] tests: lint for run-away here-doc

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 24, 2017, 02:45 UTC
Message-ID
<xmqq37e39yv7.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170324012912.GH20794@aiede.mtv.corp.google.com>
Jonathan Nieder <jrnieder@gmail.com> writes:
>> without failure (e.g. "cat" in the above example), which makes the
>> command appear to work, without eve executing the remainder of the
>
> s/eve/ever/
Oops.
Show 6 quoted lines
>> +		if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
>> +		then
>> +			error "bug in the test script: broken &&-chain or run-away HERE-DOC: $1"
>>  		fi
>
> Neat.  Why the double-LF?
The main part of "Neat" was your invention ;-).

Imagining how the string passed to eval looked, having two LFs was the easiest way to ensure that there is a blank line before the new "echo" (not just the last line in $1 and "echo" are on different lines), which was more visually pleasing. There was no any real functional requirement.

> In some shells, the 3>&1 will last past the function call.
> Fortunately, the $() substitution creates a subshell so this doesn't
> affect anything later on.

Yes, a subshell solves quite lot of problems (while possibly introducing others, though ;-).

Show 7 quoted lines
> test_eval_inner_ contains a warning not to append anything after the
> commands to be evaluated, since whatever you append would pollute -x
> tracing output.  Fortunately, in this context we have already set
> trace= so the warning does not apply.
>
>
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Thanks.
Previous: Jonathan NiederNext: Jeff King
Message 45 of 46 in “EOF test fixes (t5615/t7004)”
  1. Jan PalusMar 22, 2017
  2. Jan PalusMar 22, 2017
  3. Stefan BellerMar 22, 2017
  4. Junio C HamanoMar 22, 2017
  5. 0/3 fix "here-doc" syntax errorsJunio C Hamano, Mar 22, 2017
  6. 1/3 t5615: fix a here-doc syntax errorJunio C Hamano, Mar 22, 2017
  7. Jeff KingMar 22, 2017
  8. 2/3 t7406: fix here-doc syntax errorsJunio C Hamano, Mar 22, 2017
  9. Jeff KingMar 22, 2017
  10. Stefan BellerMar 22, 2017
  11. Jeff KingMar 22, 2017
  12. t7406: correct test case for submodule-update initial populationStefan Beller, Mar 22, 2017
  13. Jeff KingMar 22, 2017
  14. Stefan BellerMar 22, 2017
  15. Jeff KingMar 22, 2017
  16. Jonathan NiederMar 22, 2017
  17. Junio C HamanoMar 22, 2017
  18. Jeff KingMar 22, 2017
  19. Stefan BellerMar 22, 2017
  20. Junio C HamanoMar 22, 2017
  21. 3/3 t7004, t7030: fix here-doc syntax errorsJunio C Hamano, Mar 22, 2017
  22. Jeff KingMar 22, 2017
  23. Santiago TorresMar 22, 2017
  24. Jeff KingMar 22, 2017
  25. Junio C HamanoMar 22, 2017
  26. Santiago TorresMar 22, 2017
  27. Jeff KingMar 22, 2017
  28. Santiago TorresMar 22, 2017
  29. Jeff KingMar 22, 2017
  30. Junio C HamanoMar 22, 2017
  31. Santiago TorresMar 22, 2017
  32. Junio C HamanoMar 23, 2017
  33. Santiago TorresMar 23, 2017
  34. Jeff KingMar 23, 2017
  35. Junio C HamanoMar 24, 2017
  36. Jeff KingMar 24, 2017
  37. Junio C HamanoMar 24, 2017
  38. Jeff KingMar 24, 2017
  39. Jeff KingMar 24, 2017
  40. Junio C HamanoMar 22, 2017
  41. Jan PalusMar 22, 2017
  42. tests: lint for run-away here-docJunio C Hamano, Mar 23, 2017
  43. Junio C HamanoMar 23, 2017
  44. Jonathan NiederMar 24, 2017
  45. Junio C HamanoMar 24, 2017
  46. Jeff KingMar 24, 2017

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.