Commit 43bb2cef16c92712e5c72df5624e5c71edc13c05

Authored by Shrikant Sharat
1 parent 8685c068da

Variable declaration refactorings to use `local`.

Showing 1 changed file with 11 additions and 12 deletions Side-by-side Diff

... ... @@ -20,8 +20,8 @@ bundle () {
20 20 local position_args='url loc name'
21 21 local i=1
22 22 while ! [[ -z $1 || $1 == --*=* ]]; do
23   - arg_name="$(echo "$position_args" | cut -d\ -f$i)"
24   - arg_value="$1"
  23 + local arg_name="$(echo "$position_args" | cut -d\ -f$i)"
  24 + local arg_value="$1"
25 25 eval "local $arg_name='$arg_value'"
26 26 shift
27 27 i=$(($i + 1))
... ... @@ -36,8 +36,8 @@ bundle () {
36 36 # Set spec values from keyword arguments, if any. The remaining arguments
37 37 # are all assumed to be keyword arguments.
38 38 while [[ $1 == --*=* ]]; do
39   - arg_name="$(echo "$1" | cut -d= -f1 | sed 's/^--//')"
40   - arg_value="$(echo "$1" | cut -d= -f2)"
  39 + local arg_name="$(echo "$1" | cut -d= -f1 | sed 's/^--//')"
  40 + local arg_value="$(echo "$1" | cut -d= -f2)"
41 41 eval "local $arg_name='$arg_value'"
42 42 shift
43 43 done
... ... @@ -70,11 +70,10 @@ bundle () {
70 70  
71 71 bundle-install () {
72 72  
  73 + local update=false
73 74 if [[ $1 == --update ]]; then
74   - local update=true
  75 + update=true
75 76 shift
76   - else
77   - local update=false
78 77 fi
79 78  
80 79 mkdir -p "$ANTIGEN_BUNDLE_DIR"
... ... @@ -167,11 +166,11 @@ bundle-cleanup () {
167 166  
168 167 bundle-load () {
169 168  
170   - name="$1"
171   - bundle_dir="$ANTIGEN_BUNDLE_DIR/$name"
  169 + local name="$1"
  170 + local bundle_dir="$ANTIGEN_BUNDLE_DIR/$name"
172 171  
173 172 # Source the plugin script
174   - script_loc="$bundle_dir/$name.plugin.zsh"
  173 + local script_loc="$bundle_dir/$name.plugin.zsh"
175 174 if [[ -f $script_loc ]]; then
176 175 source "$script_loc"
177 176 fi
... ... @@ -234,8 +233,8 @@ echo-non-empty () {
234 233 # Same as `export $1=$2`, but will only happen if the name specified by `$1` is
235 234 # not already set.
236 235 -set-default () {
237   - arg_name="$1"
238   - arg_value="$2"
  236 + local arg_name="$1"
  237 + local arg_value="$2"
239 238 eval "test -z \"\$$arg_name\" && export $arg_name='$arg_value'"
240 239 }
241 240