No reasonable equivalent for bash's if foo="$(some command)"
#158
Closed
Description
In bash, if I write
if foo="$(some command)"; then
then the if statement will actually conditionalize based on the exit status of $(some command)
. I don't see any way to get the equivalent functionality in fish. The fundamental problem is variable assignment in fish must be done via the set
command, which overwrites $status
, and so there is no reasonable way to capture the output of a command and its return value separately. The only unreasonable way I can think of looks like
set -l oldstatus
set -l foo (some command; set oldstatus $status)
Metadata
Assignees
Labels
No labels