On Tue, Jul 6, 2021, at 5:41 PM, lisa-asket@perso.be wrote:
> In elisp, I can return an object from a function using the last command
> in the function.
Analogously, the exit status of a shell function or script is that
of the last command it executes (setting aside 'return' and 'exit'
and such).
> Does this not apply to bash functions as well? Should all bash functions only
> return a proper exit status and nothing else?
Shell functions CANNOT return anything other than exit statuses.
That is how they work.
$ f() { return hi; }; f
bash: return: hi: numeric argument required
They must use other means to convey arbitrary data. (Do not
misinterpret that error message to mean that returning numeric
results is acceptable. It is not.)
https://mywiki.wooledge.org/BashFAQ/084
--
vq