On 2019-09-07 18:57, Greg Reagle wrote:
> Okay.  I think I understand.  I'll try to give some advice.
> 
> The command 'exit' does exit the script or shell.  If you are inside a 
> function, 'return' will exit the function not the whole shell.
> 
> If you want to preserve the error code value, something like this will do:
> 
> function foo
>     ls  # this is the command that might fail
>     set error_code $status
>     if test 0 -ne $error_code 
>         echo call_error_handler
>         return $error_code
>     end
> end

Thanks. It will use something like that to safeguard code in my functions.

> If you don't need to preserve the error code, but only care about success or 
> failure, you can simplify:
> 
> ls || begin
>     echo call_error_handler
>     false
> end

Definitely the simplest and for many cases enough. This is the most
similar to something I tried. The problem was and in an "inline
function" I tried to use "return -1" which is not allowed.

Marcin

-- 
https://blog.solidsoft.info/ - Working code is not enough



_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to