Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

If it smells it's chemistry, if it crawls it's biology, if it doesn't work it's physics.


devel / comp.unix.shell / Can the exit status of the code block in @(...) be obtained from outside the @() structure?

SubjectAuthor
* Can the exit status of the code block in @(...) be obtained fromhongy...@gmail.com
+* Re: Can the exit status of the code block in @(...) be obtained fromJanis Papanagnou
|`- Re: Can the exit status of the code block in @(...) be obtained fromhongy...@gmail.com
`* Re: Can the exit status of the code block in @(...) be obtained fromJohn-Paul Stewart
 `* Re: Can the exit status of the code block in @(...) be obtained fromhongy...@gmail.com
  `* Re: Can the exit status of the code block in @(...) be obtained fromJohn-Paul Stewart
   `- Re: Can the exit status of the code block in @(...) be obtained fromhongy...@gmail.com

1
Can the exit status of the code block in @(...) be obtained from outside the @() structure?

<19b7ee13-b147-4768-a3f6-f48bca0ea6c8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4857&group=comp.unix.shell#4857

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:6214:1c81:: with SMTP id ib1mr22035434qvb.127.1642491002764;
Mon, 17 Jan 2022 23:30:02 -0800 (PST)
X-Received: by 2002:a05:620a:4455:: with SMTP id w21mr742735qkp.306.1642491002594;
Mon, 17 Jan 2022 23:30:02 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Mon, 17 Jan 2022 23:30:02 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=139.59.109.137; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 139.59.109.137
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <19b7ee13-b147-4768-a3f6-f48bca0ea6c8n@googlegroups.com>
Subject: Can the exit status of the code block in @(...) be obtained from
outside the @() structure?
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 18 Jan 2022 07:30:02 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 64
 by: hongy...@gmail.com - Tue, 18 Jan 2022 07:30 UTC

I'm trying to enhance the robustness of `install/install_utils` script
in quantum espresso package, with the following make file script as
described here[1]:

```

# Copyright (C) 2001-2016 Quantum ESPRESSO group
# # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License. See the file `License' in the root directory
# of the present distribution.
# # Utilities

###########################################################
# Template function
# $(1) = package name
# $(2) = package URL
# $(3) = directory name
# $(4) = plugin/code name
###########################################################

define download_and_unpack
@(if ! gzip -t ../archive/`echo "$(2)" | sed 's/.*\///;s/.*=//'` >
/dev/null 2>&1 ; then \
rm -fr ../archive/`echo "$(2)" | sed 's/.*\///;s/.*=//'`; \
rm -fr ../$(3); \
wget -O ../archive/`echo "$(2)" | sed 's/.*\///;s/.*=//'` $(2) >
/dev/null 2>&1; \
if test "`echo $$?`" -ne "0" ; then \
curl -o ../archive/`echo "$(2)" | sed 's/.*\///;s/.*=//'` $(2) >
/dev/null 2>&1; \
if test "`echo $$?`" -ne "0" ; then \
echo "*** Unable to download $(4). Test whether curl or wget is
installed and working," ; \
echo "*** if you have direct access to internet. If not, copy into
archive/ the file" ; \
echo "*** located here $(2)" ; \
exit 1 ; fi ; fi ; fi)
if test $? -eq 0 -a ! -e ../$(3); then \
(gzip -dc ../archive/`echo "$(2)" | sed 's/.*\///;s/.*=//'` | \
(cd ../ ; tar -xvf - ) ) ; \
if test "`echo $$?`" -ne "0" ; then \
echo "*** Unable to download $(2)." ; \
echo "*** Verify that the url is correct." ; \
exit 1 ; \
else \
(cd ../ ; ln -s $(1) $(3)) ; fi ; fi
endef
```

But it seems that the `$?' used above can't obtain the exit status of
the code block in @(...) when used from outside the @() structure [2].
So, I want to know if I can reliably obtain the exit status of the
code block in @(...) from outside the @() structure. Any hints will be
greatly appreciated. Also see here [3] for relevant discussion.

[1] https://gitlab.com/QEF/q-e/-/issues/435
[2] https://gitlab.com/QEF/q-e/-/merge_requests/1713#note_812794803
[3] https://lists.gnu.org/archive/html/help-make/2022-01/msg00016.html

Regards,
HZ

Re: Can the exit status of the code block in @(...) be obtained from outside the @() structure?

<ss5tv1$m3a$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4858&group=comp.unix.shell#4858

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Can the exit status of the code block in @(...) be obtained from
outside the @() structure?
Date: Tue, 18 Jan 2022 09:32:33 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ss5tv1$m3a$1@dont-email.me>
References: <19b7ee13-b147-4768-a3f6-f48bca0ea6c8n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jan 2022 08:32:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5f91c4ce258ba0cd6443e1ed519fa13f";
logging-data="22634"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5Yx1ItxmpRAqXYxCAM5KM"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:UI581lT3tn/sitDebpZhoy7dTd8=
In-Reply-To: <19b7ee13-b147-4768-a3f6-f48bca0ea6c8n@googlegroups.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Tue, 18 Jan 2022 08:32 UTC

On 18.01.2022 08:30, hongy...@gmail.com wrote:
> I'm trying to enhance the robustness of [...]

This is a joke, isn't it?

> [ shell-like but actually non-shell code deleted ]

Please make clear in the subject line if you refer in your post to
specific tools with non-shell syntax and name the respective tool.
(If possible post in a tool-specific forum.)

BTW, isn't it possible to create a shell script for all that shell
stuff instead of twisting the shell code to fit into that tool?

Janis

Re: Can the exit status of the code block in @(...) be obtained from outside the @() structure?

<234f165f-88bb-45ea-829c-fc268a4124c0n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4859&group=comp.unix.shell#4859

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:6214:766:: with SMTP id f6mr12207259qvz.93.1642496749225;
Tue, 18 Jan 2022 01:05:49 -0800 (PST)
X-Received: by 2002:a05:622a:1813:: with SMTP id t19mr20541915qtc.256.1642496749084;
Tue, 18 Jan 2022 01:05:49 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 18 Jan 2022 01:05:48 -0800 (PST)
In-Reply-To: <ss5tv1$m3a$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=139.59.109.137; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 139.59.109.137
References: <19b7ee13-b147-4768-a3f6-f48bca0ea6c8n@googlegroups.com> <ss5tv1$m3a$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <234f165f-88bb-45ea-829c-fc268a4124c0n@googlegroups.com>
Subject: Re: Can the exit status of the code block in @(...) be obtained from
outside the @() structure?
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 18 Jan 2022 09:05:49 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 17
 by: hongy...@gmail.com - Tue, 18 Jan 2022 09:05 UTC

On Tuesday, January 18, 2022 at 4:32:38 PM UTC+8, Janis Papanagnou wrote:
> On 18.01.2022 08:30, hongy...@gmail.com wrote:
> > I'm trying to enhance the robustness of [...]
>
> This is a joke, isn't it?

This is a serious question I don't understand. Why do you say that?
> > [ shell-like but actually non-shell code deleted ]
>
> Please make clear in the subject line if you refer in your post to
> specific tools with non-shell syntax and name the respective tool.
> (If possible post in a tool-specific forum.)
>
> BTW, isn't it possible to create a shell script for all that shell
> stuff instead of twisting the shell code to fit into that tool?

It's called by gnu make command, and I also don't know why the original author of this script wrote it so obscurely.

Re: Can the exit status of the code block in @(...) be obtained from outside the @() structure?

<j4ojupF1i7dU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4860&group=comp.unix.shell#4860

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: jpstew...@personalprojects.net (John-Paul Stewart)
Newsgroups: comp.unix.shell
Subject: Re: Can the exit status of the code block in @(...) be obtained from
outside the @() structure?
Date: Tue, 18 Jan 2022 14:49:44 -0500
Lines: 15
Message-ID: <j4ojupF1i7dU1@mid.individual.net>
References: <19b7ee13-b147-4768-a3f6-f48bca0ea6c8n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 1jx7mY62kb5KA78Ht74eoAmowXEw3SzdUuD1o92quuhebcRixc
Cancel-Lock: sha1:t7/8JJiymHUI7jdrmGXibUtBlxo=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Content-Language: en-CA
In-Reply-To: <19b7ee13-b147-4768-a3f6-f48bca0ea6c8n@googlegroups.com>
 by: John-Paul Stewart - Tue, 18 Jan 2022 19:49 UTC

On 2022-01-18 02:30, hongy...@gmail.com wrote:
> I'm trying to enhance the robustness of `install/install_utils` script
> in quantum espresso package, with the following make file script as
> described here[1]:

As the other poster alluded to, this is NOT a shell question. It is a
question about Makefile syntax. You are asking if the exit status of
shell code inside a Makefile can be accessed elsewhere in the Makefile.
In other words, completely outside the shell. So that makes it a
question for Makefile experts (maybe there is a mailing list for that)
rather than the shell experts in this newsgroup.

It is also easily answered by reading the documentation for (GNU) make
or a quick Google search. Both are things you should do before posting
here or anywhere else.

Re: Can the exit status of the code block in @(...) be obtained from outside the @() structure?

<d036c1d6-e92d-499f-830d-16492cff4a64n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4861&group=comp.unix.shell#4861

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:620a:1587:: with SMTP id d7mr20027552qkk.333.1642559027323;
Tue, 18 Jan 2022 18:23:47 -0800 (PST)
X-Received: by 2002:ad4:5ba3:: with SMTP id 3mr18092069qvq.75.1642559027170;
Tue, 18 Jan 2022 18:23:47 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 18 Jan 2022 18:23:46 -0800 (PST)
In-Reply-To: <j4ojupF1i7dU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=139.59.109.137; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 139.59.109.137
References: <19b7ee13-b147-4768-a3f6-f48bca0ea6c8n@googlegroups.com> <j4ojupF1i7dU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d036c1d6-e92d-499f-830d-16492cff4a64n@googlegroups.com>
Subject: Re: Can the exit status of the code block in @(...) be obtained from
outside the @() structure?
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 19 Jan 2022 02:23:47 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 29
 by: hongy...@gmail.com - Wed, 19 Jan 2022 02:23 UTC

On Wednesday, January 19, 2022 at 3:49:52 AM UTC+8, John-Paul Stewart wrote:
> On 2022-01-18 02:30, hongy...@gmail.com wrote:
> > I'm trying to enhance the robustness of `install/install_utils` script
> > in quantum espresso package, with the following make file script as
> > described here[1]:
> As the other poster alluded to, this is NOT a shell question. It is a
> question about Makefile syntax. You are asking if the exit status of
> shell code inside a Makefile can be accessed elsewhere in the Makefile.
> In other words, completely outside the shell. So that makes it a
> question for Makefile experts (maybe there is a mailing list for that)
> rather than the shell experts in this newsgroup.
>
> It is also easily answered by reading the documentation for (GNU) make
> or a quick Google search. Both are things you should do before posting
> here or anywhere else.

Thank you very much, I found the following example here [1]:

=== begin ===
To those who can't still fix it, the original snippet in the question missed a semicolon after mycommand. So, the working example is:

mycommand; \ # <<== here's the missing semicolon
if [ $$? -ne 0 ]; \
then \
echo "mycommand failed"; \
false; \
fi
=== end ===

[1] https://stackoverflow.com/a/70105815

Re: Can the exit status of the code block in @(...) be obtained from outside the @() structure?

<j4rmj1Fjkh5U1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4862&group=comp.unix.shell#4862

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: jpstew...@personalprojects.net (John-Paul Stewart)
Newsgroups: comp.unix.shell
Subject: Re: Can the exit status of the code block in @(...) be obtained from
outside the @() structure?
Date: Wed, 19 Jan 2022 18:53:05 -0500
Lines: 9
Message-ID: <j4rmj1Fjkh5U1@mid.individual.net>
References: <19b7ee13-b147-4768-a3f6-f48bca0ea6c8n@googlegroups.com>
<j4ojupF1i7dU1@mid.individual.net>
<d036c1d6-e92d-499f-830d-16492cff4a64n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net wkL1a0NsMdLKhqwkSt+t0Q/f6Aqn0BqQOMVazkYq5QjGaUI9rh
Cancel-Lock: sha1:bnILra125SfEehzqclFP6sq08q4=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Content-Language: en-CA
In-Reply-To: <d036c1d6-e92d-499f-830d-16492cff4a64n@googlegroups.com>
 by: John-Paul Stewart - Wed, 19 Jan 2022 23:53 UTC

On 2022-01-18 21:23, hongy...@gmail.com wrote:
>
> Thank you very much, I found the following example

Which has nothing to do with your specific question. Adding semicolons
will not help you obtain a shell's exit status in a Makefile. You
missed the relevant info on the page you cited AND you missed the point
in my previous post (and Janis' post) that this is not the place to
discuss Makefile syntax.

Re: Can the exit status of the code block in @(...) be obtained from outside the @() structure?

<6c5294e6-3d7e-4083-bdc5-183100dc7cddn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4863&group=comp.unix.shell#4863

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:620a:4110:: with SMTP id j16mr871844qko.706.1642644710344;
Wed, 19 Jan 2022 18:11:50 -0800 (PST)
X-Received: by 2002:a05:620a:270a:: with SMTP id b10mr9885178qkp.568.1642644710167;
Wed, 19 Jan 2022 18:11:50 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Wed, 19 Jan 2022 18:11:49 -0800 (PST)
In-Reply-To: <j4rmj1Fjkh5U1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=165.22.49.121; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 165.22.49.121
References: <19b7ee13-b147-4768-a3f6-f48bca0ea6c8n@googlegroups.com>
<j4ojupF1i7dU1@mid.individual.net> <d036c1d6-e92d-499f-830d-16492cff4a64n@googlegroups.com>
<j4rmj1Fjkh5U1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6c5294e6-3d7e-4083-bdc5-183100dc7cddn@googlegroups.com>
Subject: Re: Can the exit status of the code block in @(...) be obtained from
outside the @() structure?
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Thu, 20 Jan 2022 02:11:50 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 14
 by: hongy...@gmail.com - Thu, 20 Jan 2022 02:11 UTC

On Thursday, January 20, 2022 at 7:53:11 AM UTC+8, John-Paul Stewart wrote:
> On 2022-01-18 21:23, hongy...@gmail.com wrote:
> >
> > Thank you very much, I found the following example
> Which has nothing to do with your specific question. Adding semicolons
> will not help you obtain a shell's exit status in a Makefile. You
> missed the relevant info on the page you cited AND you missed the point
> in my previous post (and Janis' post) that this is not the place to
> discuss Makefile syntax.

Anyway, I've figured out the problem based on the comments given by Paul Smith here [1].

[1] https://lists.gnu.org/archive/html/help-make/2022-01/msg00019.html

HZ

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor