So, the idea is to have a script that tries to run a command, and if the command fails it shows up any warnings/errors. My try:
$ cat try.sh
#! /bin/sh
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/temp$$
trap 'rm -f $tempfile >/dev/null 2>&1' 0
trap 'exit 2' 1 2 3 15
echo "$@"
if ! "$@" >$tempfile 2>&1; then
cat $tempfile;
false;
fi
Do you think that this script is ok (wrt portability and functionality)?