Skip to content
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

Use local command properly in plugins/git/git.plugin.zsh #3962

Closed
wants to merge 2 commits into from
Closed

Use local command properly in plugins/git/git.plugin.zsh #3962

wants to merge 2 commits into from

Conversation

devunt
Copy link

@devunt devunt commented Jun 7, 2015

zsh local command will print out pair or variable name and value if it has value. [1]

What supposed to happen is:
screenshot from 2015-06-07 16 49 57

What actually happend is:
screenshot from 2015-06-07 16 38 18

[1] http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html

Prevent it from printing variable values
@devunt devunt changed the title Use local command properly Use local command properly in plugins/git/git.plugin.zsh Jun 7, 2015
@devunt
Copy link
Author

devunt commented Jun 7, 2015

CC: @ncanceill

@apjanke
Copy link
Contributor

apjanke commented Jun 8, 2015

The real issue is that this code is using local outside a function call. When used inside a function call, local <varname> does not produce output. That local git_cmd that's sitting outside a function doesn't actually localize the variable: zsh variables are dynamically, not lexically scoped. You may as well just remove that local: the way plugins are loaded now, it's not doing anything, and if the plugin were loaded from inside a function call, local-izing it would probably break things.

@devunt
Copy link
Author

devunt commented Jun 8, 2015

I know that the bash local command can't be used from the outside of function, but is the zsh same?

@apjanke
Copy link
Contributor

apjanke commented Jun 8, 2015

Local variables in zsh work the same as local variables in bash. But the local command in zsh is slightly different: you can call it outside a function. It just probably won't do what you want. Basically, you should only use local variables in zsh the same places where you would use them in bash. Inside functions, or in code that's only going to get called from inside a function.

@apjanke
Copy link
Contributor

apjanke commented Jun 8, 2015

The presence of this local may be causing #3963. The error message sounds like it's related.

@devunt devunt mentioned this pull request Jun 9, 2015
5 tasks
@ncanceill ncanceill mentioned this pull request Jun 11, 2015
8 tasks
ncanceill added a commit to ncanceill/oh-my-zsh that referenced this pull request Jun 11, 2015
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
@ncanceill
Copy link
Contributor

@devunt would you be so kind as to fetch my fork and cherry-pick 6c29041 to see if it fixes your issue?

@devunt
Copy link
Author

devunt commented Jun 11, 2015

@ncanceill it works like a charm.

@ncanceill
Copy link
Contributor

Awesome! this will be merged as soon as the other issues are solved.

@devunt
Copy link
Author

devunt commented Jun 11, 2015

Then should I close this pr now?

@ncanceill
Copy link
Contributor

You can, but even if you omit to do so, this will close when #3990 gets merged.

@devunt devunt closed this Jun 11, 2015
@devunt devunt deleted the patch-1 branch June 11, 2015 14:54
steshaw pushed a commit to steshaw/oh-my-zsh that referenced this pull request Jun 13, 2015
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
Spirotot pushed a commit to Spirotot/oh-my-zsh that referenced this pull request Jun 27, 2015
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
erwinvaneijk pushed a commit to erwinvaneijk/oh-my-zsh that referenced this pull request Jul 7, 2015
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
torbjoernk added a commit to torbjoernk/oh-my-zsh that referenced this pull request Jul 25, 2015
* master:
  virtualenvwrapper: Replace "realpath" with portable zsh-native `:A` and `:h` modifiers
  Plugin now uses completion script from docker-compose repo.
  git plugin: fix ggl to avoid empty string see ohmyzsh#2790 (comment)
  Fix plugin/git ggpull and ggpush backward compatibility
  Fix merge conflict for jira-prefix and jira add comment
  Add missing space causing parse error.
  Fixed odd chars on mac for agnoster theme
  Add mix-fast plugin (similar to rake-fast)
  Update _docker
  Adding quotes to git completion discovery path
  A paver (Python build and configuration utility) plugin
  Revert "Added migration notification for rails plugin"
  Added github in web_search plugin.
  last-working-dir working with spaces in dirnames
  use local options to set no_equals before sourcing bash completion script
  git plugin: new/changed aliases gaa was brought back by popular demand — see ohmyzsh#3535 gap was replaced with gapa — see ohmyzsh#3682 gdc was replaced with gdca — see ohmyzsh#3977
  Add reference to bundler plugin issue in README
  Add `leaves` command to `brew` completion
  remove trash command from osx plugin
  Added README.md file for ForkLift plugin
  Added README.md file for atom plugin
  Added README.md file
  Fix README.md for sst command
  Plugins: vi-mode: Add first README file
  Plugins: archlinux - add basic README.
  Plugins: archlinux - use command -v in favor of which
  Plugins: apache2-macports - add README
  Added references to the `external themes` wiki page.
  git plugin: fix ggpnp when called without argument also allow multiple arguments for ggp and ggl aliases
  * Added header with help and information * Moved git information to left prompt, with   support for:     * +ZSH_THEME_GIT_PROMPT_UNTRACKED, MODIFIED,     STASHED, ADDED, UPSTREAM STATUS     (if applicable) * Removed right prompt * Refactored following Google's guidelines for   scripts [ http://goo.gl/oJSXH2 ]     * Using local variables where applicable
  Update Mix complition upto 1.0.4
  Update aliases in laravel5.plugin.zsh file
  Update taskwarrior.plugin.zsh
  Renamed 'ss' alias to 'sstat' (to avoid collision with /bin/ss).
  Fixed typo in README
  Update bgnotify.plugin.zsh
  fix typo
  adb: add more commands
  Update README.markdown
  Fixed jump pluging to display the right mark name on 'mark . '
  Added README for mercurial plugin
  Add git to prerequisites
  add help link to install zsh
  sublime: Make subl a function so it can be called from functions in other modules
  Added support for detecting Sublime Text 3 on Arch Linux
  Update history-substring-search README
  Added the tugboat autocompletion plugin
  git plugin: make b local in gg* functions because it leaked, and led to ohmyzsh#3991
  git plugin: fix error msg in gwip alias because git rm will fail when no files were deleted
  git plugin: global var for git command due to issues like ohmyzsh#3962 until a proper plugin-loading system is implemented
  git plugin: bring back olg gg aliases by popular demand, see ohmyzsh#3972
  More run and create options
  Only load url-quote-magic if it is available. Partially fixes ohmyzsh#3614
  Disable globbing when executing `zeus rake` aliases to enable use of square brackets without escaping
  Add git_prompt_behind and git_prompt_exists
  add kitchen completion plugin from @petere
  Added a possibility to display the remote branch and the number of commits you are ahead or behind
  Fix homebrew directory in aws plugin.
  Recognize comments by default.
  Move custon *.zsh file sourcing up so that they can load plugins and other things that come after.
  added comment functionality
  Improved the `_git_time_since_commit` function.
  Remove docker insert command
  Add README for httpie plugin
  Fix typo in $VCS_CLEAN_COLOR in adben theme
  Grep bug in Agnoster
  generate with 'pod --completion-script' /cc thx to @ajmccall
  updated the command list to the latest cocoapod version (0.33.0)
  No input for Update Check defaults to Yes
  Add rdrs method to reset the database(s)
  Set AWS_PROFILE and use existing RPROMPT
  Add new boot2docker options
  Add installation instructions to README
  Round 3 of batch-closing obsolete issues
  Respect $ZSH_CACHE_DIR when creating fasd's cache
  Create new aliases for homebrew plugin
  Add sublime text 3 paths to check list
  Don't leak extendedglob to global environment.
  Detect the .venv in any parent directory of the current directory
  Add CakePHP3 plugin
  Differing upgrade and safe-upgrade
  Many updates to git plugin (see ohmyzsh#2790)
  Use $EDITOR
  Fix 'chsh' by checking '/etc/shells' instead of using 'which'
  Add alias of bundle clean
  Added aliases for docker compose
  add markdown extension to README
  Add readme and add new alias cfpc: paste+compile+copy
  Update template zshrc with HYPHEN_INSENSITIVE
  typofix
  Add coffeescript aliases: cf, cfc, cfp
  Add hyphen insensitivity
  Fixing some issues where show repeated weird values, and fixed commands that need the container autocomplete without being running, like start, now it autocompletes showing all the containers so you can start without knowing the right name
  Fix minimal.zsh-theme's check for in_svn and add support for mercurial
  Add autocomplete for frontend-search
  Fixes gradle autocomplete. Regex did not include subproject tasks before.
  fix stackoverflow url in search
  Use the newest Vundle commands
  Add stackoverflow link
  Fixed Typo.
  Use camelCase for npm aliases
  Fix echo nothing if $SHORT_HOST doesn't exist.
  Add .ipsw to the extract plugin.
  Minor cosmetic fix to minimal theme
  [boot2docker plugin] Initial version
  fix paclist() for non-english locales
  gitfast: back-port prompt fix
  gitfast: update to upstream v1.9.2
sparrc pushed a commit to sparrc/oh-my-zsh that referenced this pull request Jul 27, 2015
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
DerToti pushed a commit to DerToti/oh-my-zsh that referenced this pull request Jul 29, 2015
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
kirb pushed a commit to kirb/oh-my-zsh that referenced this pull request Aug 23, 2015
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
ChristianLohmann pushed a commit to ChristianLohmann/oh-my-zsh that referenced this pull request Aug 31, 2015
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
inutano pushed a commit to inutano/oh-my-zsh that referenced this pull request Oct 19, 2015
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
tmitchell pushed a commit to tmitchell/oh-my-zsh that referenced this pull request Mar 31, 2016
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
NobbZ pushed a commit to NobbZ/oh-my-zsh that referenced this pull request May 15, 2016
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
DennisDenuto pushed a commit to DennisDenuto/oh-my-zsh that referenced this pull request Oct 29, 2016
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
fforw pushed a commit to fforw/oh-my-zsh that referenced this pull request Feb 21, 2017
due to issues like ohmyzsh#3962
until a proper plugin-loading system is implemented
Luxcium added a commit to LuxciumProject/ahmyzsh that referenced this pull request Sep 20, 2020
https://github.com/ohmyzsh/ohmyzsh/blob/93c837fec8e9fe61509b9dff9e909e84f7ebe32d/plugins/git/git.plugin.zsh#L1-L293

Copyright (c) 2009-2020 Robby Russell and
[contributors](https://github.com/ohmyzsh/ohmyzsh/contributors)

TAnks to those who have contributed to fix those 20+ issues:

ohmyzsh/ohmyzsh#1790
ohmyzsh/ohmyzsh#3535
ohmyzsh/ohmyzsh#3682
ohmyzsh/ohmyzsh#3962
ohmyzsh/ohmyzsh#3972
ohmyzsh/ohmyzsh#3977
ohmyzsh/ohmyzsh#3991
ohmyzsh/ohmyzsh#4085
ohmyzsh/ohmyzsh#4727
ohmyzsh/ohmyzsh#5130
ohmyzsh/ohmyzsh#5179
ohmyzsh/ohmyzsh#5362
ohmyzsh/ohmyzsh#5442
ohmyzsh/ohmyzsh#6329
ohmyzsh/ohmyzsh#6793
ohmyzsh/ohmyzsh#7682
ohmyzsh/ohmyzsh#7716
ohmyzsh/ohmyzsh#7754
ohmyzsh/ohmyzsh#867
ohmyzsh/ohmyzsh#9103
ohmyzsh/ohmyzsh#9114

and those who help develop
theses aliases and function
whith theses Pull 40+ Requests:

ohmyzsh/ohmyzsh#2790
ohmyzsh/ohmyzsh#3167
ohmyzsh/ohmyzsh#4304
ohmyzsh/ohmyzsh#4751
ohmyzsh/ohmyzsh#4830
ohmyzsh/ohmyzsh#4993
ohmyzsh/ohmyzsh#5025
ohmyzsh/ohmyzsh#5178
ohmyzsh/ohmyzsh#5271
ohmyzsh/ohmyzsh#5287
ohmyzsh/ohmyzsh#5306
ohmyzsh/ohmyzsh#5307
ohmyzsh/ohmyzsh#5390
ohmyzsh/ohmyzsh#5417
ohmyzsh/ohmyzsh#5433
ohmyzsh/ohmyzsh#5511
ohmyzsh/ohmyzsh#5591
ohmyzsh/ohmyzsh#5643
ohmyzsh/ohmyzsh#5729
ohmyzsh/ohmyzsh#5844
ohmyzsh/ohmyzsh#5849
ohmyzsh/ohmyzsh#5871
ohmyzsh/ohmyzsh#6006
ohmyzsh/ohmyzsh#6031
ohmyzsh/ohmyzsh#6059
ohmyzsh/ohmyzsh#6079
ohmyzsh/ohmyzsh#6297
ohmyzsh/ohmyzsh#6378
ohmyzsh/ohmyzsh#6789
ohmyzsh/ohmyzsh#6791
ohmyzsh/ohmyzsh#6893
ohmyzsh/ohmyzsh#7064
ohmyzsh/ohmyzsh#7472
ohmyzsh/ohmyzsh#7556
ohmyzsh/ohmyzsh#7629
ohmyzsh/ohmyzsh#7630
ohmyzsh/ohmyzsh#7724
ohmyzsh/ohmyzsh#7841
ohmyzsh/ohmyzsh#8089
ohmyzsh/ohmyzsh#8563
ohmyzsh/ohmyzsh#8617
ohmyzsh/ohmyzsh#8622
ohmyzsh/ohmyzsh#8697
ohmyzsh/ohmyzsh#8902
ohmyzsh/ohmyzsh#8935
ohmyzsh/ohmyzsh#8957
ohmyzsh/ohmyzsh#9049
Signed-off-by: Benjamin Vincent (Luxcium) <luxcium@neb401.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants