diff options
author | Rob Landley <rob@landley.net> | 2019-02-01 14:51:31 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-02-01 14:51:31 -0600 |
commit | ac617315854d7985105a6cf341a5c0153fe3e35d (patch) | |
tree | 80e77ed53bf6bb36342d05746a3d560560ce6dc0 /scripts | |
parent | 46c63ae43a89a340354493ee96a4b2b5fdf87b8d (diff) | |
download | toybox-ac617315854d7985105a6cf341a5c0153fe3e35d.tar.gz |
Fix record-commands and logwrapper.c
record-commands: Delete old log, only delete $WRAPDIR at end if path wasn't
externally supplied, don't add the rm at the end to the log.
logwrapper.c: don't skip filename when measuring space for command line malloc,
use argv[0] instead of /proc/self/exe (which is realpath -f).
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/record-commands | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/scripts/record-commands b/scripts/record-commands index 0201ac31..741c3818 100755 --- a/scripts/record-commands +++ b/scripts/record-commands @@ -2,13 +2,13 @@ # Set up command recording wrapper -[ -z "$WRAPDIR" ] && WRAPDIR="$PWD"/record-commands -[ -z "$WRAPLOG" ] && export WRAPLOG="$PWD"/log.txt && CLEANUP=1 +[ -z "$WRAPDIR" ] && WRAPDIR="$PWD"/record-commands && RM=$(which rm) +[ -z "$WRAPLOG" ] && export WRAPLOG="$PWD"/log.txt if [ $# -eq 0 ] then - echo "Usage: WRAPDIR=dir WRAPLOG=log.txt record-commands command..." - echo "Then examine log.txt" + echo "Usage: WRAPDIR=dir WRAPLOG=log.txt record-commands COMMAND..." + echo 'Then examine log.txt. "record-commands echo" to just setup $WRAPDIR' exit 1 fi @@ -26,8 +26,15 @@ then done fi -PATH="$WRAPDIR:$PATH" "$@" +# Delete old log (if any) +rm -f "$WRAPLOG" + +X=0 +if [ ! -z "$1" ] +then + PATH="$WRAPDIR:$PATH" "$@" +fi X=$? -[ ! -z "$CLEANUP" ] && rm -rf "$WRAPDIR" +[ ! -z "$RM" ] && "$RM" -rf "$WRAPDIR" exit $X |