From 120f0312e7c5312878b751f812e4b5a0b39c36ae Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sun, 31 Mar 2024 23:10:54 +0200 Subject: [PATCH] util: undo custom GNU exit codes, reduce number of special cases --- util/build-gnu.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 6a4b09f89..8bdadddcf 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -279,14 +279,11 @@ sed -i "s|\$PACKAGE_VERSION|[0-9]*|g" tests/rm/fail-2eperm.sh tests/mv/sticky-to # with the option -/ is used, clap is returning a better error than GNU's. Adjust the GNU test sed -i -e "s~ grep \" '\*/'\*\" err || framework_failure_~ grep \" '*-/'*\" err || framework_failure_~" tests/misc/usage_vs_getopt.sh sed -i -e "s~ sed -n \"1s/'\\\/'/'OPT'/p\" < err >> pat || framework_failure_~ sed -n \"1s/'-\\\/'/'OPT'/p\" < err >> pat || framework_failure_~" tests/misc/usage_vs_getopt.sh -# Ignore some binaries (not built) -# And change the default error code to 2 -# see issue #3331 (clap limitation). -# Upstream returns 1 for most of the program. We do for cp, truncate & pr -# So, keep it as it -sed -i -e "s/rcexp=1$/rcexp=2\n case \"\$prg\" in chcon|runcon) return;; esac/" -e "s/rcexp=125 ;;/rcexp=2 ;;\ncp|truncate|pr) rcexp=1;;/" tests/misc/usage_vs_getopt.sh +# Ignore runcon, it needs some extra attention +# For all other tools, we want drop-in compatibility, and that includes the exit code. +sed -i -e "s/rcexp=1$/rcexp=1\n case \"\$prg\" in runcon|stdbuf) return;; esac/" tests/misc/usage_vs_getopt.sh # GNU has option=[SUFFIX], clap is -sed -i -e "s/cat opts/sed -i -e \"s| <.\*>$||g\" opts/" tests/misc/usage_vs_getopt.sh +sed -i -e "s/cat opts/sed -i -e \"s| <.\*$||g\" opts/" tests/misc/usage_vs_getopt.sh # for some reasons, some stuff are duplicated, strip that sed -i -e "s/provoked error./provoked error\ncat pat |sort -u > pat/" tests/misc/usage_vs_getopt.sh