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

Re: [PATCH 2/2] Makefile: work around ksh's failure to handle missing list argument to for loop

From
Brandon Casey <drafnel@gmail.com>
Date
Jul 5, 2010, 21:29 UTC
Message-ID
<AANLkTin0h8DUWo3sfhRdA7NCCCPLKXfQzSDvWX7p1OPq@mail.gmail.com>
In-Reply-To
<7vy6dpyeqf.fsf@alter.siamese.dyndns.org>

It looks like Johannes has already supplied the explanation that was missing from my commit message. Thanks.

On Mon, Jul 5, 2010 at 1:18 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 20 quoted lines
> Johannes Sixt <j.sixt@viscovery.net> writes:
>
>> Before the test for emptyness can happen, the complete statement must be
>> parsed, but ksh finds a syntax error in the statement and, therefore,
>> cannot even begin to execute the statement. (ksh doesn't follow POSIX in
>> this regard, where this would not be a syntax error.)
>
> I had to stare at Brandon's patch that was essentially:
>
> -    for p in $(FOO); do echo $$p; done
> +    foo=$(FOO); for p in $$foo; do echo $$p; done
>
> and the above two doesn't look like there should be any difference; your
> explanation makes quite a lot of sense but that's arcane.  I doubt I will
> be able to justify and explain the latter construction without consulting
> your message I am responsing to, if somebody asks "why do we assign $(FOO)
> to a shell variable and then iterate over it?" 6 months from now.
>
> It might make sense to use $(foreach) instead of rolling our own loop in
> the shell to avoid glitches like this.

$(foreach) works too. I only avoided it because it has already caused a problem once before by creating a command line that exceeded the maximum argument list length on IRIX.

REMOTE_CURL_ALIASES only has 3 items in it right now, and probably won't grow much larger, if it grows at all, so there is little chance of exceeding the maximum argument list length on IRIX. So $(foreach) is fine with me if you think that reads better.

-Brandon
Previous: Andreas SchwabNext: Junio C Hamano
Message 20 of 22 in “installation issue when building with NO_CURL=YesPlease”
  1. Paul WalkerMay 26, 2010
  2. Michael J GruberMay 26, 2010
  3. Paul WalkerMay 26, 2010
  4. Ramkumar RamachandraMay 26, 2010
  5. Paul WalkerMay 26, 2010
  6. Makefile: reenable install with NO_CURLMichael J Gruber, May 26, 2010
  7. Dirk SüsserottMay 26, 2010
  8. Bruce StephensMay 26, 2010
  9. Dirk SüsserottMay 26, 2010
  10. 1/2 Makefile: remove some unnecessary curly bracesBrandon Casey, Jul 2, 2010
  11. 2/2 Makefile: work around ksh's failure to handle missing list argument to for loopBrandon Casey, Jul 2, 2010
  12. Raja R HarinathJul 3, 2010
  13. Michael J GruberJul 4, 2010
  14. Johannes SixtJul 5, 2010
  15. Michael J GruberJul 5, 2010
  16. Johannes SixtJul 5, 2010
  17. Michael J GruberJul 5, 2010
  18. Junio C HamanoJul 5, 2010
  19. Andreas SchwabJul 5, 2010
  20. Brandon CaseyJul 5, 2010
  21. Junio C HamanoJul 6, 2010
  22. 2/2 Makefile: work around ksh's failure to handle missing list argument to for loopBrandon Casey, Jul 6, 2010

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.