ansitest/logecho.mrg
2022-09-07 10:41:02 -05:00

25 lines
446 B
Bash

#!/bin/bash
# Echo something to current console AND log
# Can also handle piped input ( cmd |logecho )
# Warning: Has trouble echoing '*' even when quoted.
function logecho () {
args=$@
if [ -z "$args" ]; then
args='tmp'
while [ 1 ]; do
read -e -t2 args
if [ -n "$args" ]; then
echo $args |tee -a $logfile;
else
break;
fi
done
else
echo $args |tee -a $logfile;
fi
} # END FUNC