I would like to return exit code "0" from a failed command. Is there any easier way of doing this, rather than:
function a() {
ls aaaaa 2>&1;
}
if ! $(a); then
return 0
else
return 5
fi
I would like to return exit code "0" from a failed command. Is there any easier way of doing this, rather than:
function a() {
ls aaaaa 2>&1;
}
if ! $(a); then
return 0
else
return 5
fi
Simply append
return 0
to the function to force a function to always exit successful.If you wish to do it inline for any reason you can append
|| true
to the command:If you wish to invert the exit status simple prepend the command with
!
Also if you state what you are trying to achieve overall we might be able to guide you to better answers.