# The z/OS-motivated options and the time keyword, checked on any # platform: they only add environment variables or format output. echo "-- time keyword" norm() { sed -e 's/[0-9][0-9]*/N/g'; } { time -p true; } 2>&1 | norm { time { sleep 0; :; }; } 2>&1 | norm { time -p; } 2>&1 | norm f() { :; } { time f | cat; } 2>/dev/null; echo "status $?" { time false; } 2>/dev/null; echo "status $?" { ! time -p false; } 2>/dev/null; echo "negated $?" # the report goes to the shell's stderr, not the timed command's { time -p echo out 2>/dev/null; } 2>&1 | norm time=1; echo "time as a word: $time time" g() { time -p :; } sleep 0 & { g; } 2>&1 | norm echo "-- set -o jobnames" env | grep '^_BPX_' || echo none set -o jobnames env | grep '^_BPX_JOBNAME' /usr/bin/env | grep '^_BPX_JOBNAME' _BPX_JOBNAME=MINE env | grep '^_BPX_JOBNAME' set +o jobnames env | grep -c '^_BPX_JOBNAME' echo "-- set -o shareas (foreground commands only)" set -o shareas env >out grep '^_BPX_SHAREAS' out env >all & wait grep -c '^_BPX_SHAREAS' all x=$(env | grep -c '^_BPX_SHAREAS'); echo "cmdsub/pipe: $x" _BPX_SHAREAS=NO env | grep '^_BPX_SHAREAS' set +o shareas set -o | grep -E 'jobnames|shareas|msgid' echo "-- set -o msgid" set -o msgid cd /nonexistent/dir 2>&1 | sed 's/^\(ZSH[0-9]*[EW]\) .*/\1/' ( . /nonexistent/file ) 2>&1 | sed 's/^\(ZSH[0-9]*[EW]\) .*/\1/' set +o msgid cd /nonexistent/dir 2>&1 | sed 's/^.*\(cd:\)/\1/'