git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/3] completion: be nicer with zsh
Date: Mon, 30 Jan 2012 12:30:18 +0200	[thread overview]
Message-ID: <CAMP44s2PsSj=mTZMtkteHnycqEXgO7YQeJzSuH9T734pFQiJMQ@mail.gmail.com> (raw)
In-Reply-To: <7v4nvdeo23.fsf@alter.siamese.dyndns.org>

On Mon, Jan 30, 2012 at 7:50 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> 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>"

<0,frotz nitfol xyzzy>
<0,frotz nitfol xyzzy>
<0,frotz nitfol xyzzy>

And that's _without_ bash emulation.

BTW. That code didn't work for me in bash (though it did in zsh), I
had to add a semicolon:

 bar () { echo "frotz nitfol xyzzy" ;}

> 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).

That's not the problem, the problem is that this doesn't work in zsh:

array="a b c"
for i in $array; do
 echo $i
done

The result is "a b c". Unless sh emulation is on. This is the correct
way in zsh:

array="a b c"
for i in ${=array}; do
 echo $i
done

But this behavior can be controlled with SH_WORD_SPLIT.

Anyway, as I said, the problem is that the ':' have some problems, and
sh emulation seems to be turned off inside such command, or at least
SH_WORD_SPLIT was reset in my tests.

-- 
Felipe Contreras

  reply	other threads:[~2012-01-30 10:30 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-29 23:41 [PATCH 0/3] completion: trivial cleanups Felipe Contreras
2012-01-29 23:41 ` [PATCH 1/3] completion: be nicer with zsh Felipe Contreras
2012-01-30  4:34   ` Junio C Hamano
2012-01-30  5:50     ` Junio C Hamano
2012-01-30 10:30       ` Felipe Contreras [this message]
2012-01-30 10:35     ` Felipe Contreras
2012-01-30 18:07       ` Junio C Hamano
2012-01-30 18:21         ` Felipe Contreras
2012-01-29 23:41 ` [PATCH 2/3] completion: remove old code Felipe Contreras
2012-01-30  2:36   ` Jonathan Nieder
2012-01-30  3:24     ` Felipe Contreras
2012-01-30  3:27       ` Jonathan Nieder
2012-01-30  4:27       ` Junio C Hamano
2012-01-30 10:51         ` Felipe Contreras
2012-01-30 11:19           ` Frans Klaver
2012-01-30 11:55             ` Felipe Contreras
2012-01-30 12:21               ` Frans Klaver
2012-01-30 13:59                 ` Felipe Contreras
2012-01-30 14:02                   ` Jonathan Nieder
2012-01-29 23:41 ` [PATCH 3/3] completion: remove unused code Felipe Contreras
2012-01-30  2:50   ` Jonathan Nieder
2012-01-30  3:29     ` Jonathan Nieder
2012-01-30  3:30     ` Felipe Contreras
2012-01-30  7:44       ` Thomas Rast
2012-01-30  8:22         ` Junio C Hamano
2012-01-30 10:38           ` Felipe Contreras
2012-01-30 13:19             ` Thomas Rast
2012-01-30 13:51               ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMP44s2PsSj=mTZMtkteHnycqEXgO7YQeJzSuH9T734pFQiJMQ@mail.gmail.com' \
    --to=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).