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

Re: [PATCH 1/3] completion: be nicer with zsh

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 30, 2012, 05:50 UTC
Message-ID
<7v4nvdeo23.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7v8vkperli.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
> Avoiding zsh's bug that cannot use conditional assignment on the no-op
> colon command (if the bug is really that; it is somewhat hard to imagine
> if the bug exists only for colon command, though) *is* by itself a good
> justification for this change, even though the resulting code is harder to
> read for people who are used to read shell scripts.
Just from my curiosity, I am wondering what zsh does when given these:
	bar () { echo "frotz nitfol xyzzy" }
	unset foo; : ${foo:=$(bar)}; echo "<$?,$foo>"
        unset foo; true ${foo:=$(bar)}; echo "<$?,$foo>"
        unset foo; echo >/dev/null ${foo:=$(bar)}; echo "<$?,$foo>"

The first one is exactly your "And yet another bug in zsh[1] causes a mismatch; zsh seems to have problem emulating wordspliting, but only when the ':' command is involved.", so we already know it "seems to have problem emulating word-splitting" (by the way, can we replace that with exact description of faulty symptom? e.g. "does not split words at $IFS" might be what you meant but still when we are assigning the result to a single variable, it is unclear how that matters).

Note that I am not suggesting to rewrite the existing ": ${var:=val}" with "echo ${var:val} >/dev/null" at all. Even if "echo >/dev/null" makes it work as expected, your rewrite to protect it with an explicit conditional e.g. "test -n ${foo:-} || foo=$(bar)" would be a lot better than funny construct like "echo >/dev/null ${foo:=$(bar)", because it is not an established shell idiom to use default assignment with anything but ":".

Thanks.
Previous: Junio C HamanoNext: Felipe Contreras
Message 4 of 28 in “completion: trivial cleanups”
  1. 0/3 completion: trivial cleanupsFelipe Contreras, Jan 29, 2012
  2. 1/3 completion: be nicer with zshFelipe Contreras, Jan 29, 2012
  3. Junio C HamanoJan 30, 2012
  4. Junio C HamanoJan 30, 2012
  5. Felipe ContrerasJan 30, 2012
  6. Felipe ContrerasJan 30, 2012
  7. Junio C HamanoJan 30, 2012
  8. Felipe ContrerasJan 30, 2012
  9. 2/3 completion: remove old codeFelipe Contreras, Jan 29, 2012
  10. Jonathan NiederJan 30, 2012
  11. Felipe ContrerasJan 30, 2012
  12. Jonathan NiederJan 30, 2012
  13. Junio C HamanoJan 30, 2012
  14. Felipe ContrerasJan 30, 2012
  15. Frans KlaverJan 30, 2012
  16. Felipe ContrerasJan 30, 2012
  17. Frans KlaverJan 30, 2012
  18. Felipe ContrerasJan 30, 2012
  19. Jonathan NiederJan 30, 2012
  20. 3/3 completion: remove unused codeFelipe Contreras, Jan 29, 2012
  21. Jonathan NiederJan 30, 2012
  22. Jonathan NiederJan 30, 2012
  23. Felipe ContrerasJan 30, 2012
  24. Thomas RastJan 30, 2012
  25. Junio C HamanoJan 30, 2012
  26. Felipe ContrerasJan 30, 2012
  27. Thomas RastJan 30, 2012
  28. Felipe ContrerasJan 30, 2012

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.