2

I was using this repo to run an Airflow image and noticed these lines in the Github workflow:

      - run: docker build -t "${PWD##*/}" .
      - run: docker run "${PWD##*/}" python -V
      - run: docker run "${PWD##*/}" version

I understand that docker run takes arguments of the form [OPTIONS] IMAGE [COMMAND] [ARG...], so I know that the image is being determined by "${PWD##*/}", but I am not sure what this is actually doing.

I thought it might be part of the YAML spec for Github Actions but I was unable to find a match in the documentation. After looking at the documentation for docker run I am unsure of where to look next.

What does "${PWD##*/}" signify?

1 Answer 1

3

It's not docker or github specific, but shell.

See https://www.tldp.org/LDP/abs/html/string-manipulation.html

${string##substring}

Deletes longest match of $substring from front of $string.

So the code "${PWD##*/}" deletes everything until (and including) the last slash in $PWD, so it gets the directory name without the whole path.

Another possibility would be:

"$(basename $PWD)"
1
  • This makes sense, my understanding from your answer is that it takes the result of pwd, e.g. /foo/bar/boo and returns boo
    – shayaan
    Dec 18, 2019 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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