Skip to content

Commit

Permalink
java, make: avoid errors in nounset mode on Ubuntu 14 and 16
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed May 31, 2020
1 parent 3423e14 commit 1a633f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions completions/java
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ _java_classes()
fi
done

# remove class extension
COMPREPLY=(${COMPREPLY[@]%.class})
# convert path syntax to package syntax
COMPREPLY=(${COMPREPLY[@]//\//.})
if ((${#COMPREPLY[@]} != 0)); then
# remove class extension
COMPREPLY=(${COMPREPLY[@]%.class})
# convert path syntax to package syntax
COMPREPLY=(${COMPREPLY[@]//\//.})
fi
}

# available packages completion
Expand All @@ -111,12 +113,14 @@ _java_packages()
command sed -e 's|^'$i'/||'))
fi
done
# keep only packages
COMPREPLY=($(tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$"))
# remove packages extension
COMPREPLY=(${COMPREPLY[@]%/})
# convert path syntax to package syntax
cur="${COMPREPLY[*]//\//.}"
if ((${#COMPREPLY[@]} != 0)); then
# keep only packages
COMPREPLY=($(tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$"))
# remove packages extension
COMPREPLY=(${COMPREPLY[@]%/})
# convert path syntax to package syntax
cur="${COMPREPLY[*]//\//.}"
fi
}

# java completion
Expand Down
2 changes: 1 addition & 1 deletion completions/make
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ _make()
local IFS=$' \t\n' script=$(_make_target_extract_script $mode "$cur")
COMPREPLY=($(LC_ALL=C \
$1 -npq __BASH_MAKE_COMPLETION__=1 \
"${makef[@]}" "${makef_dir[@]}" .DEFAULT 2>/dev/null |
${makef+"${makef[@]}"} "${makef_dir[@]}" .DEFAULT 2>/dev/null |
command sed -ne "$script"))

if [[ $mode != -d ]]; then
Expand Down

0 comments on commit 1a633f3

Please sign in to comment.