babelfish icon indicating copy to clipboard operation
babelfish copied to clipboard

Fish sourcing uses exit instead of return

Open hpfr opened this issue 4 years ago • 0 comments

Hi, thanks for your work on this project!

One potential issue I noticed: Fish complains about areturn from non-function in a translated file containing environment variables that was intended to be sourced by Bash. In Bash return is used for returning from functions and from files being sourced, but in Fish, exit is used. We can't change from return to exit in the sourced Bash file because it exits the shell that's sourcing, unlike fish.

Since source statements are translated by inserting calls to babelfish, maybe a -source option could be introduced indicating the Bash input should have top-level returns converted to exits? Then source statements could be translated by inserting calls to babelfish -source?

What do you think? Thanks!

hpfr avatar Jul 07 '21 00:07 hpfr