"return" should not continue script execution, even if used inappropria
From:
Robert Hailey
Subject:
"return" should not continue script execution, even if used inappropriately
Date:
Sat, 5 Jan 2019 13:16:28 -0600
To the most excellent bash maintainers:
I have found, what I consider to be a bug, in the following version of
bash:
* bash-4.4.23-1.fc28.x86_64
It is related to this error message:
* "return: can only `return' from a function or sourced script"
When used inappropriately (such as running a correctly-written script
that was merely intended to be sourced rather than executed), the
return statement does not cease execution, and "falls through" to
continue executing the script beyond the point that the author of the
script clearly indicated that it should cease into realms of arbitrary
and unexpected code paths.
Best wishes, kind regards, and heartfelt thank-you for your
dedicated service to the community.
--
Robert Hailey