Commit 3e92539689534f4e563fb95416ecb5c39f72c2c5
1 parent
3c16e1f03b
Moved `-set-default` into a private function.
Its polluting the global namespace but doesn't have the `antigen` prefix, making it hard to figure out where it came from.
Showing 1 changed file with 11 additions and 8 deletions Side-by-side Diff
antigen.zsh
| ... | ... | @@ -293,7 +293,6 @@ antigen-revert () { |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | antigen-selfupdate () { |
| 296 | - # Initiate subshell | |
| 297 | 296 | ( |
| 298 | 297 | cd $_ANTIGEN_INSTALL_DIR |
| 299 | 298 | # Sanity checks |
| ... | ... | @@ -631,6 +630,15 @@ antigen () { |
| 631 | 630 | } |
| 632 | 631 | |
| 633 | 632 | -antigen-env-setup () { |
| 633 | + | |
| 634 | + # Helper function: Same as `export $1=$2`, but will only happen if the name | |
| 635 | + # specified by `$1` is not already set. | |
| 636 | + -set-default () { | |
| 637 | + local arg_name="$1" | |
| 638 | + local arg_value="$2" | |
| 639 | + eval "test -z \"\$$arg_name\" && export $arg_name='$arg_value'" | |
| 640 | + } | |
| 641 | + | |
| 634 | 642 | # Pre-startup initializations. |
| 635 | 643 | -set-default ANTIGEN_DEFAULT_REPO_URL \ |
| 636 | 644 | https://github.com/robbyrussell/oh-my-zsh.git |
| ... | ... | @@ -643,14 +651,9 @@ antigen () { |
| 643 | 651 | |
| 644 | 652 | # Setup antigen's own completion. |
| 645 | 653 | compdef _antigen antigen |
| 646 | -} | |
| 647 | 654 | |
| 648 | -# Same as `export $1=$2`, but will only happen if the name specified by `$1` is | |
| 649 | -# not already set. | |
| 650 | --set-default () { | |
| 651 | - local arg_name="$1" | |
| 652 | - local arg_value="$2" | |
| 653 | - eval "test -z \"\$$arg_name\" && export $arg_name='$arg_value'" | |
| 655 | + # Remove private functions. | |
| 656 | + unfunction -- -set-default | |
| 654 | 657 | } |
| 655 | 658 | |
| 656 | 659 | # Setup antigen's autocompletion |