git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Thomas via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Thomas <thomasqueirozb@gmail.com>
Subject: Re: [PATCH] completion: fix zsh parsing $GIT_PS1_SHOWUPSTREAM
Date: Fri, 26 Apr 2024 01:08:09 +0000	[thread overview]
Message-ID: <Zir-eeK0CZxVLhcR@tapette.crustytoothpaste.net> (raw)
In-Reply-To: <pull.1710.git.git.1714071592035.gitgitgadget@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1345 bytes --]

On 2024-04-25 at 18:59:51, Thomas via GitGitGadget wrote:
> From: Thomas Queiroz <thomasqueirozb@gmail.com>
> 
> Since GIT_PS1_SHOWUPSTREAM is a variable with space separated values and
> zsh for loops do no split by space by default, parsing of the options
> wasn't actually being done. The `-d' '` is a hacky solution that works
> in both bash and zsh. The correct way to do that in zsh would be do use
> read -rA and loop over the resulting array but -A isn't defined in bash.

I wonder if it might actually be better to adjust the shell options when
we call into __git_ps1.  We could write this like so:

	[ -z "${ZSH_VERSION-}" ] || setopt localoptions shwordsplit

That will turn on shell word splitting for just that function (and the
functions it calls), so the existing code will work fine and we won't
tamper with the user's preferred shell options.

My concern is that changing the way we write the code here might result
in someone unintentionally changing it back because it's less intuitive.
By specifically asking zsh to use shell word splitting, we get
consistent behaviour between bash and zsh, which is really what we want
anyway.

I use the above syntax (minus the shell check) in my zsh prompt and can
confirm it works as expected.
-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2024-04-26  1:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 18:59 [PATCH] completion: fix zsh parsing $GIT_PS1_SHOWUPSTREAM Thomas via GitGitGadget
2024-04-26  1:08 ` brian m. carlson [this message]
2024-04-26  5:39   ` Junio C Hamano

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=Zir-eeK0CZxVLhcR@tapette.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=thomasqueirozb@gmail.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).