Skip to content

Commit

Permalink
refactor: prefer grep --quiet over standard output redirection (#1655)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall authored Jan 9, 2024
1 parent dfea89c commit d7e0740
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/commands/command-plugin-test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/reshim.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/functions/versions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down

0 comments on commit d7e0740

Please sign in to comment.