refactor: prefer grep --quiet over standard output redirection (#1655)

This commit is contained in:
Edwin Kofler 2024-01-09 04:39:18 -08:00 committed by GitHub
parent dfea89ccc7
commit d7e0740461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -79,7 +79,7 @@ plugin_test_command() {
fi
# shellcheck disable=SC2119
if ! (plugin_list_command | grep "^$plugin_name$" >/dev/null); then
if ! (plugin_list_command | grep -q "^$plugin_name$"); then
fail_test "$plugin_name was not properly installed"
fi
@ -90,8 +90,8 @@ plugin_test_command() {
local plugin_path
plugin_path=$(get_plugin_path "$plugin_name")
local list_all="$plugin_path/bin/list-all"
if grep api.github.com "$list_all" >/dev/null; then
if ! grep Authorization "$list_all" >/dev/null; then
if grep -q api.github.com "$list_all"; then
if ! grep -q Authorization "$list_all"; then
printf "\nLooks like %s/bin/list-all relies on GitHub releases\n" "$plugin_name"
printf "but it does not properly sets an Authorization header to prevent\n"
printf "GitHub API rate limiting.\n\n"

View File

@ -18,7 +18,7 @@ remove_shim_for_version() {
sed -i.bak -e "/# asdf-plugin: $plugin_name $version"'$/d' "$shim_path"
rm "$shim_path".bak
if ! grep "# asdf-plugin:" "$shim_path" >/dev/null ||
if ! grep -q "# asdf-plugin:" "$shim_path" ||
[ "$count_installed" -eq 0 ]; then
rm -f "$shim_path"
fi

View File

@ -60,7 +60,7 @@ version_command() {
resolved_versions+=("$version")
done
if [ -f "$file" ] && grep "^$plugin_name " "$file" >/dev/null; then
if [ -f "$file" ] && grep -q "^$plugin_name " "$file"; then
local temp_dir
temp_dir=${TMPDIR:-/tmp}