Author: Unknown
Subject: pipe true and false
Date: Friday, 11 Dec 2020, 21:17:50
The spec says > reporting the status of the last simple command, pipeline, conditional command, or subcommand executed by setting the environment variable $? to its "printed" value (e.g., the string "0" if the value is zero). In the staff solution: $ echo hi | sfdsfd $ printenv ? 2 But also $ sfdsfd | echo hi $ printenv ? 2 Why wouldn't I expect the second one to be 0? sfdsfd is an unknown file. If the first non-zero error message is supposed to be returned then what explains this? $ sfdsfd | sfdsfd | echo hi $ printenv ? 2 $ sfdsfd | sfdsfd | test $ printenv ? 1 Where "test" is a known file. "test" by itself returns 1 and "echo hi" by itself returns 0PREV INDEX NEXT