Commit 60d0dc5712253e92cad0a1feafc0ed1d50b916e0
1 parent
de2f0c562c
Refactor to private function and remove repetition.
Showing 1 changed file with 5 additions and 7 deletions Side-by-side Diff
antigen.zsh
| ... | ... | @@ -87,7 +87,7 @@ bundle-install () { |
| 87 | 87 | install_bundles="$(echo "$bundles" | tail -1)" |
| 88 | 88 | else |
| 89 | 89 | # Install all the plugins, previously recorded. |
| 90 | - install_bundles="$(echo-non-empty "$bundles")" | |
| 90 | + install_bundles="$(-bundle-echo-record)" | |
| 91 | 91 | fi |
| 92 | 92 | |
| 93 | 93 | # If the above `if` is directly piped to the below `while`, the contents |
| ... | ... | @@ -144,7 +144,7 @@ bundle-cleanup () { |
| 144 | 144 | |
| 145 | 145 | # Find directores in ANTIGEN_BUNDLE_DIR, that are not in the bundles record. |
| 146 | 146 | local unidentified_bundles="$(comm -13 \ |
| 147 | - <(echo-non-empty "$bundles" | awk '{print $1}' | sort) \ | |
| 147 | + <(-bundle-echo-record | awk '{print $1}' | sort) \ | |
| 148 | 148 | <(ls -1 "$ANTIGEN_BUNDLE_DIR"))" |
| 149 | 149 | |
| 150 | 150 | if [[ -z $unidentified_bundles ]]; then |
| ... | ... | @@ -221,15 +221,13 @@ bundle-list () { |
| 221 | 221 | echo "You don't have any bundles." >&2 |
| 222 | 222 | return 1 |
| 223 | 223 | else |
| 224 | - echo-non-empty "$bundles" | awk '{print $1 " " $2 " " $3}' | |
| 224 | + -bundle-echo-record | awk '{print $1 " " $2 " " $3}' | |
| 225 | 225 | fi |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | # Does what it says. |
| 229 | -echo-non-empty () { | |
| 230 | - echo "$@" | while read line; do | |
| 231 | - [[ $line != "" ]] && echo $line | |
| 232 | - done | |
| 229 | +-bundle-echo-record () { | |
| 230 | + echo "$bundles" | sed -n '1!p' | |
| 233 | 231 | } |
| 234 | 232 | |
| 235 | 233 | -bundle-env-setup () { |