In bash, I notice that if a command using redirection would fail, any programs which run prior to that are not run.
For example, this program opens the file "a" and writes 50 bytes to file "a". However, running this command with redirection to a file with insufficient permissions (~root/log), yields no change in file size of "a".
$ ./write_file.py >> ~root/log -bash: /var/root/log: Permission denied cdal at Mac in ~/experimental/unix_write $ ls -lt total 16 -rw-rw-r-- 1 cdal staff 0 Apr 27 08:54 a <-- SHOULD BE 50 BYTES
One would think the program would run, capture any output (but also write to the file "a"), and then fail to write any output to ~root/log. Instead the program is never run.
Why is this, and how does bash choose the order of the "checks" it performs prior to executing a program? Are other checks performed as well?
p.s. I'm trying to determine whether a program run under cron actually ran when redirected to a "permission denied" file.