9

I have some script and I didn't understand a line which contains $(1):

wget --retry-connrefused --waitretry=5 --read-timeout=30 --tries=50 --no-dns-cache https://dataverse.harvard.edu/api/access/datafile/:persistentId?persistentId=doi:$(1) -O data/tmp.tar.gz

What does $(1) represent?

0

1 Answer 1

11

$(1) is the first argument to a GNU make “function”, which is a variable interpreted by the call function:

define dataverse_download
    wget --retry-connrefused --waitretry=5 --read-timeout=30 --tries=50 --no-dns-cache https://dataverse.harvard.edu/api/access/datafile/:persistentId?persistentId=doi:$(1) -O data/tmp.tar.gz
    cd data && tar -xzf tmp.tar.gz
    rm -f data/tmp.tar.gz
endef

download_wget:
    mkdir -p data
    $(call dataverse_download,10.7910/DVN/IA8UOS/URG8XN)
    $(call dataverse_download,10.7910/DVN/IA8UOS/1DBE7K)
    $(call dataverse_download,10.7910/DVN/IA8UOS/34QRHK)

This defines a function, dataverse_download, which downloads the datafile matching the DOI given as the first argument; the download_wget target shows how to use this with the $(call) function.

1
  • 1
    @StephenKitt you've been served, feel free to revert. Notice that $(1) is the same as $1 or ${1}, just like any other one-character macro like $@ or a = b ... $a.
    – user313992
    Feb 24, 2020 at 11:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .