8

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?

10

$(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.

|improve this answer|||||
  • 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. – mosvy Feb 24 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.