Skip to content

set -x causes $(...) to return incorrect results #250

@certik

Description

@certik

Consider the following ci/version.sh script:

#!/usr/bin/env shell

set -ex

version=$(git describe --tags --dirty)
echo "|${version}|"

This will print:

$ shell ci/version.sh
+ version=+ git describe --tags --dirty v0.45.0-368-g7534e5ade-dirty
+ echo |+ git describe --tags --dirty v0.45.0-368-g7534e5ade-dirty|
|+ git describe --tags --dirty v0.45.0-368-g7534e5ade-dirty|

This is incorrect. Rather, it should print the following, which it does when you remove "set -x":

$ shell ci/version.sh
|v0.45.0-368-g7534e5ade-dirty|

The $version variable is incorrect with set -x.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions