bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Execution of subsequent commands after a command crashes.


From: Robert Elz
Subject: Re: Execution of subsequent commands after a command crashes.
Date: Tue, 03 Feb 2026 10:29:38 +0700

    Date:        Tue, 3 Feb 2026 10:13:06 +0800
    From:        =?UTF-8?B?546L5Lyf?= <northisland2017@gmail.com>
    Message-ID:  
<CAPGy_BaNuxjAARLeYHrUrEaUdD3qxKpS4zYOsKxX6j6324WJTw@mail.gmail.com>


  | The second method above also won't work. Isn't the purpose of a semicolon
  | to create a new line? Does it have some other side effect?

Yes, the shell parses the entire command, until it has finished, and
a newline appears - if there's a shell detected error, the entire
parsed command is aborted.

In the case

        test_crash
        if ...

the "test_crash" will be parsed and executed (and fail), then the
shell will read the if (all of it) and execute that.

In
        test_crash; anything_else

the shell will read and parse all of that (to the end of anything_else)
and then execute it.   test_trash aborts with a shell error, nothing
else is executed.

kre

ps: it is really dumb to use bash extensions when standard portable
POSIX shell code works equally well, "[[ $? -ne 0 ]]" is not in the
slightest different from "[ $? -ne 0 ]" and the latter will work in
any shell - so use the latter, not the former.   This of course makes
absolutely no difference to the point of these messages.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]