You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a proposal to make command substitutions modify $status. Currently, the exit status of command substitutions is just discarded.
This will usually have no effect, because command substitutions must be passed to another command, which will overwrite status:
echo (false)
$status will be 0, because it reflects the result of echo, not false.
However, some commands do not modify status, such as switch. This allows us to determine whether the command succeeded:
switch (uname)
case Linux
echo "You're on Linux"
case Darwin
echo "You're OS X"
case '*'
if test $status = 0
echo "You are on another system"
else
echo "uname failed"
end
end
Another change is that $status will reflect the value of a command substitution within a prior argument:
echo (false) $status (true) $status
This will now output "1 0", which matches the behavior of bash and zsh.
The most significant benefit of this is that it allows a "transparent set", as in #214:
if set path (which python)
echo "Python is at $path"
else
echo "Python is not installed"
end
Without this change, it is far more difficult to determine whether which failed.
This only affects command substitutions run by user code. Internal uses, such as fish_prompt, will not change the exit status.
The text was updated successfully, but these errors were encountered:
Looks cool.
The only limitation I see is that it will be only helpful for the internal commands.
All the external commands which are used with command substitutions will override the status. But this is a minor issue. The benefits of this feature are going to cover most of the needs.
This is a proposal to make command substitutions modify
$status
. Currently, the exit status of command substitutions is just discarded.This will usually have no effect, because command substitutions must be passed to another command, which will overwrite status:
$status
will be 0, because it reflects the result ofecho
, notfalse
.However, some commands do not modify status, such as
switch
. This allows us to determine whether the command succeeded:Another change is that
$status
will reflect the value of a command substitution within a prior argument:This will now output "1 0", which matches the behavior of bash and zsh.
The most significant benefit of this is that it allows a "transparent set", as in #214:
Without this change, it is far more difficult to determine whether
which
failed.This only affects command substitutions run by user code. Internal uses, such as
fish_prompt
, will not change the exit status.The text was updated successfully, but these errors were encountered: