help-make
[Top][All Lists]
Advanced

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

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


From: Hongyi Zhao
Subject: Can the exit status of the code block in @(...) be obtained from outside the @() structure?
Date: Tue, 18 Jan 2022 10:14:23 +0800

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.

[1] https://gitlab.com/QEF/q-e/-/issues/435
[2] https://gitlab.com/QEF/q-e/-/merge_requests/1713#note_812794803

Regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



reply via email to

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