[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "return" should not continue script execution, even if used inapprop
From: |
don fong |
Subject: |
Re: "return" should not continue script execution, even if used inappropriately |
Date: |
Thu, 24 Jan 2019 17:20:37 -0800 |
>
> Encapsulate your code in a main function and deal with it.
>
yes, exactly. and that supposedly "crazy" python convention (its bash
equivalent) is the best way i know of to "deal with it".
On Thu, Jan 24, 2019 at 4:08 PM konsolebox <konsolebox@gmail.com> wrote:
> Encapsulate your code in a main function and deal with it.
>
> -- konsolebox/m
>
> On Mon, Jan 21, 2019, 12:39 PM Robert Elz <kre@munnari.oz.au wrote:
>
>> Date: Sun, 20 Jan 2019 17:43:04 -0800
>> From: don fong <dfong@dfong.com>
>> Message-ID: <
>> CAHQakpXao-pBDR2e0tNHH_iouHLWDXQ_FcCbzo1gxRhpfv915A@mail.gmail.com>
>>
>> | 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.
>>
>> That's fine, if you are writing something to work like this, you
>> just make sure that it will work when run either way. That means
>> rthat you cannot do a "return" outside of a function in the script.
>>
>> This is easy to accomplish, the code just needs to be written
>> to meet both sets of requirements (if you want to finish in a reliable
>> way, you execute to EOF, and don't use either exit or return).
>>
>> | the script should do nothing but define stuff when dotted in;
>> | but call the main function (or some other function) when run at the
>> top
>> | level. "sh -c '. script'" doesn't accomplish that.
>>
>> No, but it allows you to test a script that is not written to be able
>> to be run either way, someone's script that is only intended to be
>> executed as ". script" which you then want to test. In many cases
>> you might need to add more than just the '.' command - depending
>> on what is in the script (as I said way back in my first message on
>> this subject).
>>
>> kre
>>
>>
>>
- Re: "return" should not continue script execution, even if used inappropriately, (continued)
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/07
- Re: "return" should not continue script execution, even if used inappropriately, Greg Wooledge, 2019/01/07
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/07
- Re: "return" should not continue script execution, even if used inappropriately, don fong, 2019/01/09
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/10
- Re: "return" should not continue script execution, even if used inappropriately, don fong, 2019/01/20
- Re: "return" should not continue script execution, even if used inappropriately, Greg Wooledge, 2019/01/21
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/20
- Re: "return" should not continue script execution, even if used inappropriately, konsolebox, 2019/01/24
- Re: "return" should not continue script execution, even if used inappropriately,
don fong <=
- Re: "return" should not continue script execution, even if used inappropriately, konsolebox, 2019/01/24
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/24
- Re: "return" should not continue script execution, even if used inappropriately, don fong, 2019/01/25
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/25
- Re: "return" should not continue script execution, even if used inappropriately, don fong, 2019/01/25
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/27