Re: [PATCH 2/5] ci/lib: allow running in GitHub Actions
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 12, 2020, 22:12 UTC
- Message-ID
- <xmqqimi4cq0v.fsf@gitster.c.googlers.com>
- In-Reply-To
- <nycvar.QRO.7.76.6.2004122339290.46@tvgsbejvaqbjf.bet>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 11 quoted lines
> As to the "It works as expected", this is in a Bash: > > $ test "$CI_OS_NAME" = macos && CI_OS_NAME=osx > > $ echo $? > 1 > > Yes, it works, but in the common case, it exits with an error (that we > ignore, unless run with `sh -e ...`). > > Just making sure that we're talking about the same expectation here.
My expectation is that "set -e" won't prevent anything that comes after "make sure we set CI_OS_NAME to osx on macos but do not do so on other platforms" we see above from running. In other words, with a script like this:
$ cat >X <<\EOF
#!/bin/sh
set -x -e
CI_OS_NAME=linux echo different
test "$CI_OS_NAME" = macos && CI_OS_NAME=OSX CI_OS_NAME=macos
echo same
test "$CI_OS_NAME" = macos && CI_OS_NAME=OSXecho both passed
false
echo at the very end
EOFI would expect all "echo" would execute, except for the last one that is not reached because of the "false", which is the first "2.9.3 list" whose last "2.9.2 pipeline"[*1*] yields a non-zero status, would stop the execution. Two 'test' before && may yield success or failure and they may control whether the assignment to CI_OS_NAME is done or skipped, but I expect that they do not affect how "set -e" behaves.
$ bash X
+ CI_OS_NAME=linux
+ echo different
different
+ test linux = macos
+ CI_OS_NAME=macos
+ echo same
same
+ test macos = macos
+ CI_OS_NAME=OSX
+ echo both passed
both passed
+ false $ dash X
+ CI_OS_NAME=linux
+ echo different
different
+ test linux = macos
+ CI_OS_NAME=macos
+ echo same
same
+ test macos = macos
+ CI_OS_NAME=OSX
+ echo both passed
both passed
+ false[Footnote]
*1* these two words are from the shell grammar https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09