If a shell is asked to perform a probably useless (or partially useless) command known to terminate, such as
cat hugeregularfile.txt > /dev/null, can it skip that command's execution (or execute a cheaper equivalent, say,
touch -a hugeregularfile.txt)?
More generally, is the shell similar to C compilers in that it may perform any transformation on the source code, so long as the externally observable behaviour is as-if the abstract machine evaluated it?
Nota Bene: My question as originally posed had a title that asked whether the shell is permitted to do these optimizations, not whether it should or even whether implementations that can do them exist. I'm interested in the theory more than the practice, although both are welcome.