[aklug] Re: bash die

From: Christopher Howard <choward@indicium.us>
Date: Wed Sep 15 2010 - 16:26:22 AKDT

On 09/15/2010 04:10 PM, James wrote:
> I'd be careful with those challenges.. Arthur once wrote an init
> system completely in Awk; I think it was mostly for the 'Awkward init'
> pun.
>
> James Gibson
>
> On 9/15/10, Christopher Howard<choward@indicium.us> wrote:
>> On 09/15/2010 01:19 PM, Arthur Corliss wrote:
>>> On Wed, 15 Sep 2010, Christopher Howard wrote:
>>>
>>>> Say you have a bash script where if any command fails, the scripts
>>>> should stop. What would be the sensible way to deal with that?
>>>>
>>>> I was thinking, write some kind of die function, and then for each
>>>> command:
>>>>
>>>> command_1 || die("command_1 failed")
>>>> mount /this/file || die("failed to mount important filesystem")
>>>> ...
>>>>
>>>> Or is there some better way to do this?
>>>
>>> Don't use bash, use make. That's exactly what it was designed to do.
>>>
>>> --Arthur Corliss
>>> Live Free or Die
>>> ---------
>>> To unsubscribe, send email to<aklug-request@aklug.org>
>>> with 'unsubscribe' in the message body.
>>>
>>
>> I was of the understand that make doesn't preserve variable assignments
>> across commands, which means you couldn't do something like this:
>>
>> VAR=`ls`
>> echo $VAR
>>
>> If I'm wrong, write me a Makefile that proves it.
>>
>> And how do you write functions in a Makefile?
>>
>> --
>> Christopher Howard
>> http://frigidcode.com
>> http://theologia.indicium.us
>>
>> ---------
>> To unsubscribe, send email to<aklug-request@aklug.org>
>> with 'unsubscribe' in the message body.
>>
>>
>

Heh, that wasn't meant as a challenge. I'm just saying that Make does
not preserve assigned variable values across commands, and if I'm wrong
I'd need a working demonstration to convince me.

Frankly, make sucks for any /real/ scripting work, which is why we have
our whole automake system for rewriting Makefiles.

-- 
Christopher Howard
http://frigidcode.com
http://theologia.indicium.us
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Sep 15 16:26:33 2010

This archive was generated by hypermail 2.1.8 : Wed Sep 15 2010 - 16:26:33 AKDT