Running if(test -e /){ echo musthappen if(test -e /notthere) echo wonthappen } if not{ echo canthappen } yields just 'musthappen' You were perhaps afraid it would also print canthappen? Looks like td sets the variable to true before the comparison and to false on the way out of an if body (see Xwastrue and where its emitted). No reason to have a stack.