On 6/5/25 8:56 PM, Shin'ichiro Kawasaki wrote:
In bash script development, it is a good practice to handle errors strictly using "set -e" or "set -o errexit". When this option is enabled, bash exits immediately upon encountering an error. There have been discussions about implementing this strict error-checking mechanism in blktests test cases [1]. Recently, these discussions were revisited, and it has been proposed to enable this strict error-checking for a limited subset of test cases [2]. However, the error-checking does not work as expected, even when each test case does "set -e", because the error-checking has certain exceptions relevant to execution contexts. According to the bash man page, "The shell doe not exit ... part of the test following the if or elif reserved words, ... or if the command's return value is being inverted with !". The blktests test case execution context applies to these exceptions. To ensure that "set -e" behaves as intended in test cases, avoid the if statements and the return value inversions (!) in the test case execution context.
Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx>