From bbedf8d1c05186f8ca39dec48507898e551e3895 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sun, 2 Nov 2025 17:01:18 +0100 Subject: [PATCH] src/bin/grepc: Use if/then/fi instead of && It will allow using 'set -Eeuo pipefail' and trap(1) ERR. Signed-off-by: Alejandro Colomar --- src/bin/grepc | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/bin/grepc b/src/bin/grepc index 1758320df..ef1ea565e 100755 --- a/src/bin/grepc +++ b/src/bin/grepc @@ -141,7 +141,9 @@ while getopts "A:B:C:chilm:nrt:x:" opt; do done; shift $((OPTIND-1)); -test $# -lt 1 && grepc_err "Missing identifier."; +if test $# -lt 1; then + grepc_err "Missing identifier."; +fi; identifier=$1; shift; @@ -203,30 +205,30 @@ patterns="$(mktemp -t grepc.patterns.XXXXXX)"; ( if test "$x" = 'c'; then - test "$t_e" = yes && grepc_c_e "$identifier"; - test "$t_fp" = yes && grepc_c_fp "$identifier"; - test "$t_fd" = yes && grepc_c_fd "$identifier"; - test "$t_flp" = yes && grepc_c_flp "$identifier"; - test "$t_fld" = yes && grepc_c_fld "$identifier"; - test "$t_fgp" = yes && grepc_c_fgp "$identifier"; - test "$t_fgd_libm" = yes && grepc_c_fgd_libm "$identifier"; - test "$t_fgd_libio" = yes && grepc_c_fgd_libio "$identifier"; - test "$t_mf" = yes && grepc_c_mf "$identifier"; - test "$t_mo" = yes && grepc_c_mo "$identifier"; - test "$t_t_braced" = yes && grepc_c_t_braced "$identifier"; - test "$t_t_td_simple" = yes && grepc_c_t_td_simple "$identifier"; - test "$t_t_td_braced" = yes && grepc_c_t_td_braced "$identifier"; - test "$t_t_td_func" = yes && grepc_c_t_td_func "$identifier"; - test "$t_ue" = yes && grepc_c_ue "$identifier"; - test "$t_uf_def" = yes && grepc_c_uf_def "$identifier"; - test "$t_uf_linux_def" = yes && grepc_c_uf_linux_def "$identifier"; - test "$t_um" = yes && grepc_c_um "$identifier"; - test "$t_ut_su" = yes && grepc_c_ut_su "$identifier"; - test "$t_ut_td_simple" = yes && grepc_c_ut_td_simple "$identifier"; - test "$t_ut_td_su" = yes && grepc_c_ut_td_su "$identifier"; + if test "$t_e" = yes; then grepc_c_e "$identifier"; fi; + if test "$t_fp" = yes; then grepc_c_fp "$identifier"; fi; + if test "$t_fd" = yes; then grepc_c_fd "$identifier"; fi; + if test "$t_flp" = yes; then grepc_c_flp "$identifier"; fi; + if test "$t_fld" = yes; then grepc_c_fld "$identifier"; fi; + if test "$t_fgp" = yes; then grepc_c_fgp "$identifier"; fi; + if test "$t_fgd_libm" = yes; then grepc_c_fgd_libm "$identifier"; fi; + if test "$t_fgd_libio" = yes; then grepc_c_fgd_libio "$identifier"; fi; + if test "$t_mf" = yes; then grepc_c_mf "$identifier"; fi; + if test "$t_mo" = yes; then grepc_c_mo "$identifier"; fi; + if test "$t_t_braced" = yes; then grepc_c_t_braced "$identifier"; fi; + if test "$t_t_td_simple" = yes; then grepc_c_t_td_simple "$identifier"; fi; + if test "$t_t_td_braced" = yes; then grepc_c_t_td_braced "$identifier"; fi; + if test "$t_t_td_func" = yes; then grepc_c_t_td_func "$identifier"; fi; + if test "$t_ue" = yes; then grepc_c_ue "$identifier"; fi; + if test "$t_uf_def" = yes; then grepc_c_uf_def "$identifier"; fi; + if test "$t_uf_linux_def" = yes; then grepc_c_uf_linux_def "$identifier"; fi; + if test "$t_um" = yes; then grepc_c_um "$identifier"; fi; + if test "$t_ut_su" = yes; then grepc_c_ut_su "$identifier"; fi; + if test "$t_ut_td_simple" = yes; then grepc_c_ut_td_simple "$identifier"; fi; + if test "$t_ut_td_su" = yes; then grepc_c_ut_td_su "$identifier"; fi; elif test "$x" = 'mk'; then - test "$t_r" = yes && grepc_mk_r "$identifier"; - test "$t_v" = yes && grepc_mk_v "$identifier"; + if test "$t_r" = yes; then grepc_mk_r "$identifier"; fi; + if test "$t_v" = yes; then grepc_mk_v "$identifier"; fi; fi; ) >"$patterns"; -- 2.47.3