]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tools: checkusage can dump all command output
authorRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 27 Jun 2017 06:25:22 +0000 (08:25 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 27 Jun 2017 06:25:22 +0000 (08:25 +0200)
use
$ make CU_DUMP=1 checkusage

for easily reviewing and comparing all output in
  /tmp/checkusage--help
  /tmp/checkusage--version
  /tmp/checkusage--unknownopt

This was a big help when doing all my last usage cleanup.
Actually I used it to dump the original output, edited it
how I would like it, and then changed our programs to match
the wanted output.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
tools/checkusage.sh

index 3d573a2536492e6fb4233ccb9536daa98443a0cb..6cde8fbf62a43f74b4a8c36e441a0dc52e378792 100755 (executable)
@@ -14,6 +14,9 @@ fi
 builddir="."
 cmds=$(echo $@ | tr ' ' '\n' | sort)
 
+# set env to dump all output to files
+test -z "$CU_DUMP" || rm -f /tmp/checkusage--{help,version,unknownopt}
+
 ## Set alternative options for --help, --version
 ## or --unknownopt. "x" means "not implemented".
 ##
@@ -32,6 +35,7 @@ function exec_option {
        local cmdb=$1
        local cmd=$2
        opt=$3
+       local tofile="/tmp/checkusage$opt"
 
        local alt="alt_${cmdb}${opt}"
        alt=${alt//-/_}
@@ -44,6 +48,12 @@ function exec_option {
                opt=$alt
        fi
 
+       test -z "$CU_DUMP" || {
+               echo "##########################################################"
+               echo "#### $cmdb"
+               $cmd $opt
+       } >> "$tofile" 2>&1
+
        out=$("$cmd" $opt 2>/dev/null)
        err=$("$cmd" $opt 2>&1 >/dev/null)
        ret=$?