I'm debugging a sh
script. What's the behavior of these lines of code?
SOME_VAR=$(env)
if [ ! -z ${SOME_VAR+x} ]; then
echo "SOMETHING HAPPENED "
fi
What does +x
mean in this case? It turns out that code works fine with bash
, but no with sh
.
EDIT: I'm working with the deployment of an Eclipse Che local instance like it's explained here.
I installed the Eclipse Che CLI that is a .sh script:
$ curl -sL https://raw.githubusercontent.com/eclipse/che/master/che.sh > /usr/local/bin/che
$ chmod +x /usr/local/bin/che
To make it work, I need to run it using bash
:
$ bash che start
If I debug the script...
$ sh -x che start
The script fails here:
get_list_of_che_system_environment_variables() {
[...]
if [ ! -z ${CHE_VARIABLES+x} ]; then
env | grep CHE_ >> $DOCKER_ENV
RETURN=$DOCKER_ENV
fi
Something is not working. If you say the substitution should work in .sh too, what would be the problem?