Run this bash script:
#!/bin/bash
while read -e line
do
wrapper "$line"
done
In its simplest form, wrapper
could consist of eval "$LINE"
. You mentioned wanting to have timings, so maybe instead have time eval "$line"
. You wanted to capture exit status, so this should be followed by the line save=$?
. And, you wanted to capture the first few lines of stdout, so some redirecting is in order. And so on.
MORE: Jo So suggests that handling for multiple-line bash commands be included. In its simplest form, if eval returns with "syntax error: unexpected end of file", then you want to prompt for another line of input before proceeding. Better yet, to check for proper bash commands, run bash -n <<<"$line"
before you do the eval
. If bash -n
reports the end-of-line error, then prompt for more input to add to `$line'. And so on.