Skip to content

Commit 6a5cad5

Browse files
committed
protect against grep broken pipe
1 parent 7dc2c01 commit 6a5cad5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

usr/bin/dist-installer-cli

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ get_installer_package_version() {
178178
return 0
179179
fi
180180
## Do not use commit-hash replace-me as search string to avoid replacement script replacing this.
181-
if ! printf '%s' "${version}" | grep --quiet --fixed-strings -- "replace-me" ; then
181+
if ! printf '%s' "${version}" | grep --fixed-strings -- "replace-me" >/dev/null ; then
182182
true "INFO: version variable does not match replace-me string."
183183
return 0
184184
fi
185-
if ! printf '%s' "${0}" | grep --quiet -- '^/usr/bin' ; then
185+
if ! printf '%s' "${0}" | grep -- '^/usr/bin' >/dev/null ; then
186186
true "INFO: variable 0 does not match ^/usr/bin string. This means not for example /usr/bin/dist-installer-cli. So not packages dist-installer-cli version."
187187
return 0
188188
fi
189-
if ! printf '%s' "${me}" | grep --quiet --fixed-strings -- "installer-cli" ; then
189+
if ! printf '%s' "${me}" | grep --fixed-strings -- "installer-cli" >/dev/null ; then
190190
true "INFO: program name variable does not match installer-cli string."
191191
return 0
192192
fi
@@ -431,7 +431,7 @@ secure_boot_test() {
431431
local mokutil_output_sb_state
432432
secure_boot_dkms_key_enrolled=""
433433
if mokutil_output_sb_state=$(root_cmd mokutil --sb-state 2>&1) ; then
434-
if printf '%s' "$mokutil_output_sb_state" | grep --quiet --ignore-case --fixed-strings -- "enabled" ; then
434+
if printf '%s' "$mokutil_output_sb_state" | grep --ignore-case --fixed-strings -- "enabled" >/dev/null; then
435435
secure_boot_status_pretty="'enabled' (mokutil_output_sb_state: '$mokutil_output_sb_state')"
436436
secure_boot_status_short=true
437437
## sudo mokutil --test-key /var/lib/dkms/mok.pub
@@ -441,10 +441,10 @@ secure_boot_test() {
441441
## Redirection '2>&1' not necessary yet but that could be considered a minor bug in mokutil to write to stdout instead
442442
## of writing to stderr.
443443
secure_boot_mokutil_dkms_test_key="$(root_cmd mokutil --test-key "/var/lib/dkms/mok.pub" 2>&1)" || true
444-
if printf '%s' "$secure_boot_mokutil_dkms_test_key" | grep --quiet --ignore-case --fixed-strings -- "already enrolled" ; then
444+
if printf '%s' "$secure_boot_mokutil_dkms_test_key" | grep --ignore-case --fixed-strings -- "already enrolled" >/dev/null ; then
445445
secure_boot_dkms_key_enrolled=true
446446
fi
447-
elif printf '%s' "$mokutil_output_sb_state" | grep --quiet --ignore-case --fixed-strings -- "disabled" ; then
447+
elif printf '%s' "$mokutil_output_sb_state" | grep --ignore-case --fixed-strings -- "disabled" >/dev/null ; then
448448
secure_boot_status_short=false
449449
secure_boot_status_pretty="'disabled' (mokutil_output_sb_state: '$mokutil_output_sb_state')"
450450
else
@@ -623,9 +623,9 @@ update_sources() {
623623

624624
if update_output=$(root_cmd_loglevel=notice root_cmd "${update_cmd[@]}" 2>&1 | "${console_write_command[@]}") ; then
625625
true "INFO: Exit code is zero but that does not guarantee in case of dnf that there is no error."
626-
if printf '%s' "$update_output" | grep --quiet --ignore-case -- "Error:" ; then
626+
if printf '%s' "$update_output" | grep --ignore-case -- "Error:" >/dev/null ; then
627627
log error "${underline}Package List Update:${nounderline} Exit code was 0 but 'Error:' found in output."
628-
if printf '%s' "$update_output" | grep --quiet --ignore-case -- "GPG signature verification error: Signing key not"; then
628+
if printf '%s' "$update_output" | grep --ignore-case -- "GPG signature verification error: Signing key not" >/dev/null; then
629629
log warn "${underline}Package List Update:${nounderline} Signing key not found. Skipping due to 'rpm --import' failing to import keys, but '--assumeyes' being used will import keys."
630630
return 0
631631
fi
@@ -669,7 +669,7 @@ check_upgrades_simulation() {
669669
&& upgrade_simulate_cmd+=( "${install_pkg_fasttrack_extra_args_maybe[@]}" )
670670
if upgrade_simulate_output=$(root_cmd_loglevel=notice root_cmd "${upgrade_simulate_cmd[@]}" 2>&1 | "${console_write_command[@]}") ; then
671671
true "INFO: Exit code is zero but that does not guarantee in case of dnf that there is no error."
672-
if printf '%s' "$upgrade_simulate_output" | grep --quiet --ignore-case -- "Error:" ; then
672+
if printf '%s' "$upgrade_simulate_output" | grep --ignore-case -- "Error:" >/dev/null ; then
673673
log error "${underline}Package Upgrade Simulation:${nounderline} Exit code was 0 but 'Error:' found in output."
674674
upgrade_simulate_sources_error
675675
fi
@@ -769,7 +769,7 @@ install_pkg() {
769769
log info "special_args: '${special_args[*]}'"
770770

771771
if ! root_cmd "${pkg_mngr_install[@]}" "${special_args[@]}" "${pkg_not_installed[@]}"; then
772-
if printf '%s' "${pkg_not_installed[*]}" | grep --quiet --ignore-case -- "virtualbox" ; then
772+
if printf '%s' "${pkg_not_installed[*]}" | grep --ignore-case -- "virtualbox" >/dev/null; then
773773
virtualbox_installation_failure_debug
774774
fi
775775
die 1 "${underline}Package Installation:${nounderline} Failed to install package: '${pkg_not_installed[*]}'"

0 commit comments

Comments
 (0)