X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=logq-function;fp=logq-function;h=0000000000000000000000000000000000000000;hb=634a9faf0514608dc9559800292025a573fbe780;hp=afe722fbbeab25b79787fa918f08c2732768ddd5;hpb=b9e35010945b3c40b5f1cc485e575ee5a41c3ad2;p=log-quiet diff --git a/logq-function b/logq-function deleted file mode 100644 index afe722f..0000000 --- a/logq-function +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -logq () { - local help="Usage: logq [-h|--help] COMMAND [ARG...] - -Log Quietly. Run COMMAND with ARGs, log to temp file. Output return code, -command, and log path. - -Minor details: Use logsave if available, which adds informational header/footer -to log file. Logfile is put in random temp dir, with filename made from the -alphanumeric characters of COMMAND + ARGs." - - if [[ $1 == --help || $1 == -h ]]; then - echo "$help" - return - fi - if [[ $# == 0 ]]; then - echo "error: need 1 or more arguments -$help" - return 1 - fi - - local index=0 - local x prettycommand - for x in "$@"; do - prettycommand+="[$index]$x " - index=$(( index+1 )) - done - - - local file="$*" - file="$(mktemp -d)/${file//[^[:alnum:]]/}" - - printf "%s\n%s\n\n" "log of $prettycommand" "$(date)" >"$file" - - # we will propagate any errors - local e=$- - [[ $e == *e* ]] && set +e - "$@" &>> "$file" - local ret=$? - [[ $e == *e* ]] && set -e - - printf "\n%s\n%s\n%s" "----------------" "$(date)" "end of log" >>"$file" - - echo -n "\$?=$ret " - echo -n "$prettycommand" - echo "[log] $file" - return $ret -}