]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
src/bin/grepc: Use if/then/fi instead of &&
authorAlejandro Colomar <alx@kernel.org>
Sun, 2 Nov 2025 16:01:18 +0000 (17:01 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sun, 2 Nov 2025 17:52:21 +0000 (18:52 +0100)
It will allow using 'set -Eeuo pipefail' and trap(1) ERR.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/bin/grepc

index 1758320dfa7dc1853bb4c515d592db01f510bf44..ef1ea565e028d967ad3f9c08bab3e73318496b22 100755 (executable)
@@ -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";