!HBsLKoOIEEOkxAeQvC:matrix.org

Opencast Community

76 Members
opencast.org – Latest release: 10.1/9.7 – Join the technical meeting: Tuesday, 3pm UTC at meet.opencast.video (p: welcome)8 Servers

Load older messages


SenderMessageTime
3 Aug 2021
@mtneug:matrix.orgMatthias Neugebauer set -e is defined in some manuals as "Exit immediately if a command exits with a non-zero status." 11:34:44
@mtneug:matrix.orgMatthias Neugebauer (set -x only prints out what commands are running and could be removed from this example) 11:35:23
@mtneug:matrix.orgMatthias Neugebauer ziegenberg: did you try running it? :) 11:35:32
@mtneug:matrix.orgMatthias Neugebauer * ziegenberg: did you try running it? :) 11:35:37
@ziegenberg:matrix.orgziegenbergno, I tried guessing it11:35:57
@ziegenberg:matrix.orgziegenberg:)11:36:12
@ziegenberg:matrix.orgziegenbergdid try it now11:37:46
@mtneug:matrix.orgMatthias Neugebauer With set -e I would expect 1. and 2. to echo nothing and 3. to echo "exit with 1" 11:37:50
@mtneug:matrix.orgMatthias Neugebauer So echo "Still running" should never run 11:38:09
@ziegenberg:matrix.orgziegenberg nah, for the second and third, both are run in the background, so I guess the set -e is not handed down 11:38:54
@ziegenberg:matrix.orgziegenbergthat's my guess11:39:38
@mtneug:matrix.orgMatthias Neugebauernot running in the background so not the explanation :) 11:39:52
@ziegenberg:matrix.orgziegenbergor call it subshell11:40:14
@mtneug:matrix.orgMatthias Neugebaueragain not a subshell. The PID stays the same11:41:29
@mtneug:matrix.orgMatthias Neugebauer A complete manual (e.g. here from bash) has something more to say, how set -e actually works. It turns out that if you have a list of commands connected with && or || this flag is ignored even for function execution. So fail will not exit if any command fails during its execution. This is apparently part of POSIX and will therefore not change. 11:48:22
@ziegenberg:matrix.orgziegenberg
Exit immediately if a pipeline (which may consist of a single simple command), a list, or a compound command (see SHELL GRAMMAR above), exits with a non-zero status. The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test following the if or elif reserved words,
part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted with !. If a compound command other than a subshell returns a non-zero status because a command failed while -e was being ignored, the shell does not exit.
11:48:32
@ziegenberg:matrix.orgziegenberg *

Exit immediately if a pipeline (which may consist of a single simple command), a list, or a compound command (see SHELL GRAMMAR above), exits with a non-zero status. The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test following the if or elif reserved words, **part of any command executed in a && or || list except the command following the fi‐

nal && or ||**, any command in a pipeline but the last, or if the command's return value is being inverted with !. If a compound command other than a subshell returns a non-zero status because a command failed while -e was being ignored, the shell does not exit. A trap on ERR, if set, is executed before the shell exits. This option applies to the shell environment and each subshell environment separately (see COMMAND EXECUTION EN‐
VIRONMENT above), and may cause subshells to exit before executing all the commands in the subshell.

11:49:03
@ziegenberg:matrix.orgziegenberg *
Exit immediately if a pipeline (which may consist of a single simple command), a list, or a compound command (see SHELL GRAMMAR above), exits with a non-zero status. The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test following the if or elif reserved words,
part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command's return value is being inverted with !. If a compound command other than a subshell returns a non-zero status because a command failed while -e was being ignored, the shell does not exit.
11:49:50
@ziegenberg:matrix.orgziegenbergyeah, that's what I just found in the man pages11:50:05
* @ziegenberg:matrix.orgziegenberg learned something new today11:51:09
@mtneug:matrix.orgMatthias Neugebauer This was very unexpected to me. I often use command || handle error, but if command is a function, this can be problematic. 11:51:41
@ziegenberg:matrix.orgziegenberghttps://unix.stackexchange.com/questions/49017212:02:27
@ziegenberg:matrix.orgziegenberg

so the following might work for you?

set -ex
fail() {
	{
		false && echo "Still running";
	} || false
}
fail || echo "exit with $?"
12:09:46
@ziegenberg:matrix.orgziegenbergIt's a bit more verbose though12:10:37
@ziegenberg:matrix.orgziegenberg *

so the following might work for you?

set -ex
fail() {
	{
		false && echo "Still running";
	} || false
}
fail || echo "exit with $?"
12:10:50
@mtneug:matrix.orgMatthias Neugebauer

This will do

set -ex
fail() {
  false && echo "Still running";
}
fail || echo "exit with $?"
12:11:26
@mtneug:matrix.orgMatthias Neugebauer The thing is fail() is in real life much longer and connecting everything with && within is not practical (except for Dockerfiles of course πŸ˜…) 12:12:43
4 Aug 2021
@lkiesow:chat.virtuos.uni-osnabrueck.deLars Kiesow Matthias Neugebauer: Since you were also complining about the Editor build architecture, do you also want to review https://github.com/opencast/opencast/pull/2879 ? Ludwig already reviewed and approved that one and if you don't see the need for yourself reviewing this too, I would go ahread and merge it. 17:13:11
@lkiesow:chat.virtuos.uni-osnabrueck.deLars Kiesow mliradelc: Do you have time for a review of https://github.com/opencast/opencast/pull/2879 this week? (Trying to get some of my pull requests reviewed) 17:56:13
@mliradelc:matrix.orgmliradelc
In reply to @lkiesow:chat.virtuos.uni-osnabrueck.de
mliradelc: Do you have time for a review of https://github.com/opencast/opencast/pull/2879 this week? (Trying to get some of my pull requests reviewed)
Yeah sure
18:23:20

There are no newer messages yet.


Back to Room List