Re: Execution of subsequent commands after a command crashes.

Robert Elz <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Message-ID <[email protected]>
    Date:        Tue, 3 Feb 2026 10:13:06 +0800
    From:        =?UTF-8?B?546L5Lyf?= <[email protected]>
    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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.