[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "return" should not continue script execution, even if used inapprop
From: |
Bize Ma |
Subject: |
Re: "return" should not continue script execution, even if used inappropriately |
Date: |
Mon, 21 Jan 2019 16:46:59 -0400 |
------------------------------
*From*: Greg Wooledge
*Subject*: Re: "return" should not continue script execution, even if used
inappropriately
*Date*: Mon, 21 Jan 2019 09:01:33 -0500
------------------------------
On Sun, Jan 20, 2019 at 05:43:04PM -0800, don fong wrote:
>* i don't see how this helps. the point is to have one file of code that*
>* behaves differently depending on whether it's dotted in or executed at the*
>* top level.*
https://mywiki.wooledge.org/BashFAQ/109
This seems to work:
[ "$BASH_SOURCE" = "$0" ] && echo "This file is meant to be sourced,
not executed" && exit 1
[ "$BASH_VERSION" ] || { echo "Please use bash" ; return 3; }
[[ "${BASH_VERSINFO[0]}" -le 2 ]] && echo 'No BASH_SOURCE array
variable' && return 2
echo "this file seems to be sourced"
- Re: "return" should not continue script execution, even if used inappropriately,
Bize Ma <=