Bash script that selects a Git tag fails since some days

Hello,
We are facing continuously failing scripts in the last days. The arguments that we pass to scripts are ignored, which looks like something has changed on bash side.

https://travis-ci.org/github/SAP/luigi/jobs/722800040#L242
This is a test with one of the scripts failing, it does not properly detect the arguments anymore.

Our implementation on reading the arguments, which we also use in other scripts (that are also failing now)

Any ideas what could have been changed?

Thanks, Markus

This code is at fault:

  if [ "latest" = "$TAG" ]; then
    LATEST_LOCAL_TAG=`(git tag -l | tail -1)`
    TAG="$LATEST_LOCAL_TAG";
  fi

Since Travis does a shallow clone by default, it can very well be that no tags are on the current branch within 50 commits from the tip. I’ve also seen this effect in PR branches from forks. Then git tag -l prints nothing, with the result that you see.


Also check out https://wiki-dev.bash-hackers.org/scripting/debuggingtips#making_xtrace_more_useful for an easy way to debug your Bash scripts.