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

Re: [PATCH] git-prompt: changes == to = for zsh's sake

From
Aaron Schrab <aaron@schrab.com>
Date
Jul 21, 2020, 00:23 UTC
Message-ID
<20200721002309.GA178512@pug.qqx.org>
In-Reply-To
<pull.679.git.1595287052428.gitgitgadget@gmail.com>
At 23:17 +0000 20 Jul 2020, "David J. Malan via GitGitGadget" <gitgitgadget@gmail.com> wrote:
Show 6 quoted lines
>From: "David J. Malan" <malan@harvard.edu>
>
>When using git-prompt.sh with Zsh, __git_ps1 currently errs
>when inside a repo with:
>
>__git_ps1:96: = not found

That depends if zsh's `equals` option is set or not. If it's set (as it is by default) you'll get that behavior. If it's unset (`setopt no_equals`) that should behave as in bash. But, it fixing the code to work regardless of shell options is definitely a good thing.

>This commit changes `==` to `=` for both Bash and Zsh.

An alternate fix would be to switch to using double square brackets instead of single square brackets for the test. Since contents of double brackets have their own parsing rules the `equals` option doesn't apply there, and so `==` is available for checking equality same as in bash. IMHO, this provides saner behavior in general; although it's definitely not POSIX compliant.

Previous: David J. Malan via GitGitGadgetNext: Junio C Hamano
Message 5 of 6 in “git-prompt: changes == to = for zsh's sake”
  1. git-prompt: changes == to = for zsh's sakeDavid J. Malan via GitGitGadget, Jul 20, 2020
  2. Junio C HamanoJul 20, 2020
  3. Elijah NewrenJul 21, 2020
  4. git-prompt: change == to = for zsh's sakeDavid J. Malan via GitGitGadget, Jul 21, 2020
  5. Aaron SchrabJul 21, 2020
  6. Junio C HamanoJul 21, 2020

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.