Commit 260f1270b9afffe6b9c68daca7de192d43008c06

Authored by Shrikant Sharat

Merge pull request #51 from jmatth. Fix #51.

Showing 1 changed file Side-by-side Diff

... ... @@ -271,7 +271,7 @@ antigen-revert () {
271 271 # Source the plugin script.
272 272 # FIXME: I don't know. Looks very very ugly. Needs a better
273 273 # implementation once tests are ready.
274   - local script_loc="$(ls "$location" | grep -m1 '\.plugin\.zsh$')"
  274 + local script_loc="$(ls "$location" | grep '\.plugin\.zsh$' | head -n1)"
275 275  
276 276 if [[ -f $location/$script_loc ]]; then
277 277 # If we have a `*.plugin.zsh`, source it.
... ... @@ -288,12 +288,12 @@ antigen-revert () {
288 288 source "$location/init.zsh"
289 289 fi
290 290  
291   - elif ls "$location" | grep -qm1 '\.zsh$'; then
  291 + elif ls "$location" | grep -l '\.zsh$' &> /dev/null; then
292 292 # If there is no `*.plugin.zsh` file, source *all* the `*.zsh`
293 293 # files.
294 294 for script ($location/*.zsh(N)) source "$script"
295 295  
296   - elif ls "$location" | grep -qm1 '\.sh$'; then
  296 + elif ls "$location" | grep -l '\.sh$' &> /dev/null; then
297 297 # If there are no `*.zsh` files either, we look for and source any
298 298 # `*.sh` files instead.
299 299 for script ($location/*.sh(N)) source "$script"
... ... @@ -573,7 +573,7 @@ antigen () {
573 573 local name="${${name_spec%\?}%:}"
574 574 local value="$1"
575 575  
576   - if echo "$code" | grep -qm1 "^local $name="; then
  576 + if echo "$code" | grep -l "^local $name=" &> /dev/null; then
577 577 echo "Argument '$name' repeated with the value '$value'". >&2
578 578 return
579 579 fi
... ... @@ -615,13 +615,14 @@ antigen () {
615 615 local value="${arg#*=}"
616 616 fi
617 617  
618   - if echo "$code" | grep -qm1 "^local $name="; then
  618 + if echo "$code" | grep -l "^local $name=" &> /dev/null; then
619 619 echo "Argument '$name' repeated with the value '$value'". >&2
620 620 return
621 621 fi
622 622  
623 623 # The specification for this argument, used for validations.
624   - local arg_line="$(echo "$keyword_args" | grep -m1 "^$name:\??\?")"
  624 + local arg_line="$(echo "$keyword_args" |
  625 + egrep "^$name:?\??" | head -n1)"
625 626  
626 627 # Validate argument and value.
627 628 if [[ -z $arg_line ]]; then
... ... @@ -629,12 +630,14 @@ antigen () {
629 630 echo "Unknown argument '$name'." >&2
630 631 return
631 632  
632   - elif (echo "$arg_line" | grep -qm1 ':') && [[ -z $value ]]; then
  633 + elif (echo "$arg_line" | grep -l ':' &> /dev/null) &&
  634 + [[ -z $value ]]; then
633 635 # This argument needs a value, but is not provided.
634 636 echo "Required argument for '$name' not provided." >&2
635 637 return
636 638  
637   - elif (echo "$arg_line" | grep -vqm1 ':') && [[ ! -z $value ]]; then
  639 + elif (echo "$arg_line" | grep -vl ':' &> /dev/null) &&
  640 + [[ -n $value ]]; then
638 641 # This argument doesn't need a value, but is provided.
639 642 echo "No argument required for '$name', but provided '$value'." >&2
640 643 return