Several issues with thes shell scripts.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
puppet-openstack-integration |
Invalid
|
Medium
|
Unassigned |
Bug Description
The shell script got two issues that may lead to strange problems.
First test like this is used
[ -z $foo ]
If you do this on the shell you see the problem:
unset foo
[ -z $foo ] && echo Yeah
Yeah
[ -n $foo ] && echo Yeah
Yeah
This is always working. In the "-z" this is not too much of the
problem as the logic table is still ok (when foo is set, it works as
expected) but the "-n" case is troublesome. To avoid any refactoring
mistake the correct way to use it should be used anyway:
[ -z "${foo}" ]
Second, the test:
[ $PUPPET_VERSION == 4 ]
is wrong. This should be:
[ "${PUPPPET_
First when the $PUPPET_VERSION is unset this raises:
bash: [: ==: unary operator expected
Then the "==" operator should be used with [[ <test> ]] not [ <test> ]
and finally "==" is the patern matching operation. I assume that the
regular operation was what was wanted here.
Changed in puppet-openstack-integration: | |
status: | Incomplete → Invalid |
For the first case I assume that's why we have
[ ! -z $GEM_HOME ]
instead of
[ -n $GEM_HOME ]