in reply to Re: Capture Exit Code Using Pipe & Tee
in thread Capture Exit Code Using Pipe & Tee

Both true and untrue misleading(?). It's getting the return/error code of the shell, yes. However, the shell is getting it from the tee command. If tee were to return 1, the shell would return 1, regardless of what make did.

merlyn's answer is definitely the right track. Doing this in perl is actually not that bad, and though it may take more code than shmem's response, I'm not sure it'd be less readable ;-)

  • Comment on Re^2: Capture Exit Code Using Pipe & Tee

Replies are listed 'Best First'.
Re^3: Capture Exit Code Using Pipe & Tee
by ikegami (Patriarch) on Jan 31, 2007 at 22:53 UTC

    No, it doesn't necessarily get it from the tee command, and it always gets it from the shell when the it is called. I can think of three circumstances where it does not.

    • If the shell can't execute tee, the error code would not be that of tee.
    • If the shell exits due to a signal or a core dump, the error code would not be that of tee. (Right?)
    • If the script runs under Windows and tee returns an error code greater than 1, the error code returned would be 1.