Skip to content

Update zsh syntax in internal/cmd/shell_zsh.go #1075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

ericbn
Copy link
Contributor

@ericbn ericbn commented Mar 14, 2023

  • Semicolon not needed at end of command.

  • [@] not needed if variable is not within "". Anyway, the quotes would only serve to expand empty-string entries in the array, which should not exist here.

  • Simplify test for occurence of _direnv_hook in array. This syntax also works with what was previously reported in Zsh direnv hook errors on "paramter not set" #803:

    $ set -euo pipefail
    $ typeset -ag precmd_functions
    $ print $precmd_functions
    
    $ print ${precmd_functions[(I)_direnv_hook]}
    0
    $ print "${precmd_functions[(r)_direnv_hook]+1}"
    
    $ print ${precmd_functions[(r)_direnv_hook]}
    zsh: precmd_functions[(r)_direnv_hook]: parameter not set
    

* Semicolon not needed at end of command.
* `[@]` not needed if variable is not within `""`. Anyway, the quotes
  would only serve to expand empty-string entries in the array, which
  should not exist here.
* Simplify test for occurence of `_direnv_hook` in array. This syntax
  also works with what was previously reported in #803:

      $ set -euo pipefail
      $ typeset -ag precmd_functions
      $ print $precmd_functions

      $ print ${precmd_functions[(I)_direnv_hook]}
      0
      $ print "${precmd_functions[(r)_direnv_hook]+1}"

      $ print ${precmd_functions[(r)_direnv_hook]}
      zsh: precmd_functions[(r)_direnv_hook]: parameter not set
@zimbatm zimbatm merged commit 5e19b5b into direnv:master Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants