I'd like to create a bash function that can get a bash code block like time does:
time {
echo 123
echo "Something else"
sleep 1
}
Basically I'd like to be able to wrap the block with my bash code.
Edit: Updated my question after the first answer of @DavidPostill♦ and the comments:
For example, I'd like to wrap a code block with 2>&1 > /dev/null and also the time it with time. Should I write a program outside bash to do that?
function myfunction() {
time { $1 } 2>&1 /dev/null
}
myfunction { sleep 1 }
Edit 2: Upon further reading it seems like it isn't possible as time is a special case for bash.