summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRuediger Meier2017-06-27 08:25:22 +0200
committerRuediger Meier2017-06-27 08:25:22 +0200
commit99267518a6f2293eee7352b72e88cac1d985ecbe (patch)
tree1d4fb1ca464fdd1465201ce4679d231b3dc4d84f /tools
parenttools: ignore unsafe commands in checkusage.sh (diff)
downloadkernel-qcow2-util-linux-99267518a6f2293eee7352b72e88cac1d985ecbe.tar.gz
kernel-qcow2-util-linux-99267518a6f2293eee7352b72e88cac1d985ecbe.tar.xz
kernel-qcow2-util-linux-99267518a6f2293eee7352b72e88cac1d985ecbe.zip
tools: checkusage can dump all command output
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>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/checkusage.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/checkusage.sh b/tools/checkusage.sh
index 3d573a253..6cde8fbf6 100755
--- a/tools/checkusage.sh
+++ b/tools/checkusage.sh
@@ -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=$?