Several issues with thes shell scripts.

Bug #1561539 reported by Sofer Athlan-Guyot
6
This bug affects 1 person
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_VERSION}" = 4 ]

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.

Revision history for this message
Sofer Athlan-Guyot (sofer-athlan-guyot) wrote :

For the first case I assume that's why we have

    [ ! -z $GEM_HOME ]

instead of

    [ -n $GEM_HOME ]

Revision history for this message
Cody Herriges (ody-cat) wrote :

Could you please indicate where these issues are in each script? A quick look and it looks like some of your recommendations are already implemented.

Changed in puppet-openstack-integration:
importance: Undecided → Medium
status: New → Incomplete
Changed in puppet-openstack-integration:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.