bashisms found in /bin/sh scripts

Bug #1561232 reported by Adrian Otto
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Magnum
Fix Committed
Low
Unassigned

Bug Description

 There are several shell scripts that contain bash specific syntax. This is problematic for the Debian package linter that expects ISO chell syntax. Here are all the scripts to fix:

$ checkbashisms `find . -name "*.sh" -print`
script ./magnum/tests/contrib/gate_hook.sh is already a bash script; skipping
script ./magnum/tests/contrib/copy_instance_logs.sh does not appear to be a /bin/sh script; skipping
script ./magnum/tests/contrib/post_test_hook.sh is already a bash script; skipping
possible bashism in ./magnum/templates/swarm/fragments/write-network-config.sh line 14 (should be 'b = a'):
if [ "$FLANNEL_USE_VXLAN" == "true" ]; then
possible bashism in ./magnum/templates/swarm/fragments/add-proxy.sh line 17 ($BASH_SOMETHING):
    if [ -f "$BASH_RC" ]; then
possible bashism in ./magnum/templates/swarm/fragments/add-proxy.sh line 18 ($BASH_SOMETHING):
        echo "declare -x http_proxy=$HTTP_PROXY" >> $BASH_RC
possible bashism in ./magnum/templates/swarm/fragments/add-proxy.sh line 20 ($BASH_SOMETHING):
        echo "File $BASH_RC does not exist, not setting http_proxy"
possible bashism in ./magnum/templates/swarm/fragments/add-proxy.sh line 25 ($BASH_SOMETHING):
    if [ -f $BASH_RC ]; then
possible bashism in ./magnum/templates/swarm/fragments/add-proxy.sh line 26 ($BASH_SOMETHING):
        echo "declare -x https_proxy=$HTTPS_PROXY" >> $BASH_RC
possible bashism in ./magnum/templates/swarm/fragments/add-proxy.sh line 28 ($BASH_SOMETHING):
        echo "File $BASH_RC does not exist, not setting https_proxy"
possible bashism in ./magnum/templates/swarm/fragments/add-proxy.sh line 32 ($BASH_SOMETHING):
if [ -f "$BASH_RC" ]; then
possible bashism in ./magnum/templates/swarm/fragments/add-proxy.sh line 34 ($BASH_SOMETHING):
        echo "declare -x no_proxy=$NO_PROXY" >> $BASH_RC
possible bashism in ./magnum/templates/swarm/fragments/add-proxy.sh line 36 ($BASH_SOMETHING):
        echo "declare -x no_proxy=$SWARM_API_IP,$ETCD_SERVER_IP,$SWARM_NODE_IP" >> $BASH_RC
possible bashism in ./magnum/templates/swarm/fragments/add-proxy.sh line 39 ($BASH_SOMETHING):
    echo "File $BASH_RC does not exist, not setting no_proxy"
script ./magnum/templates/swarm/fragments/disable-selinux.sh does not appear to have a #! interpreter line;
you may get strange results
possible bashism in ./magnum/templates/swarm/fragments/configure-docker-storage.sh line 7 (${foo:3[:1]}):
    device_name=$(ls /dev/disk/by-id | grep ${DOCKER_VOLUME:0:20}$)
possible bashism in ./magnum/templates/swarm/fragments/configure-docker-storage.sh line 14 (let ...):
    let attempts--
possible bashism in ./magnum/templates/swarm/fragments/write-docker-service.sh line 26 (should be 'b = a'):
if [ $TLS_DISABLED == 'False' ]; then
script ./magnum/templates/mesos/fragments/configure-mesos-master.sh is already a bash script; skipping
possible bashism in ./magnum/templates/mesos/fragments/add-proxy.sh line 11 ($BASH_SOMETHING):
    if [ -f "$BASH_RC" ]; then
possible bashism in ./magnum/templates/mesos/fragments/add-proxy.sh line 12 ($BASH_SOMETHING):
        echo "export http_proxy=$HTTP_PROXY" >> $BASH_RC
possible bashism in ./magnum/templates/mesos/fragments/add-proxy.sh line 14 ($BASH_SOMETHING):
        echo "File $BASH_RC does not exist, not setting http_proxy"
possible bashism in ./magnum/templates/mesos/fragments/add-proxy.sh line 21 ($BASH_SOMETHING):
    if [ -f $BASH_RC ]; then
possible bashism in ./magnum/templates/mesos/fragments/add-proxy.sh line 22 ($BASH_SOMETHING):
        echo "export https_proxy=$HTTPS_PROXY" >> $BASH_RC
possible bashism in ./magnum/templates/mesos/fragments/add-proxy.sh line 24 ($BASH_SOMETHING):
        echo "File $BASH_RC does not exist, not setting https_proxy"
possible bashism in ./magnum/templates/mesos/fragments/add-proxy.sh line 32 ($BASH_SOMETHING):
if [ -f "$BASH_RC" ]; then
possible bashism in ./magnum/templates/mesos/fragments/add-proxy.sh line 34 ($BASH_SOMETHING):
        echo "export no_proxy=$NO_PROXY" >> $BASH_RC
possible bashism in ./magnum/templates/mesos/fragments/add-proxy.sh line 37 ($BASH_SOMETHING):
    echo "File $BASH_RC does not exist, not setting no_proxy"
script ./magnum/templates/mesos/fragments/configure-mesos-slave.sh is already a bash script; skipping
possible bashism in ./magnum/templates/kubernetes/fragments/enable-kube-proxy-master.sh line 5 ('function' is useless):
function init_templates {
possible bashism in ./magnum/templates/kubernetes/fragments/configure-kubernetes-minion.sh line 10 (should be 'b = a'):
if [ "$TLS_DISABLED" == "True" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/configure-kubernetes-minion.sh line 35 (should be 'b = a'):
if [ "$NETWORK_DRIVER" == "flannel" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/configure-kubernetes-master.sh line 15 (should be 'b = a'):
if [ "$TLS_DISABLED" == "True" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/enable-kube-proxy-minion.sh line 5 ('function' is useless):
function init_templates {
possible bashism in ./magnum/templates/kubernetes/fragments/enable-kube-proxy-minion.sh line 8 (should be 'b = a'):
    if [ "${TLS_DISABLED}" == "True" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/write-kube-os-config.sh line 8 (${parm/?/pat[/str]}):
AUTH_URL=${AUTH_URL/v3/v2}
possible bashism in ./magnum/templates/kubernetes/fragments/make-cert.sh line 23 (should be 'b = a'):
if [ "$TLS_DISABLED" == "True" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/make-cert.sh line 30 (alternative test command ([[ foo ]] should be [ foo ])):
if [[ -n "${MASTER_HOSTNAME}" ]]; then
possible bashism in ./magnum/templates/kubernetes/fragments/configure-flannel.sh line 8 (should be 'b = a'):
if [ "$FLANNEL_USE_VXLAN" == "true" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/make-cert-client.sh line 23 (should be 'b = a'):
if [ "$TLS_DISABLED" == "True" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/write-network-config.sh line 21 (should be 'b = a'):
if [ "$FLANNEL_USE_VXLAN" == "true" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/enable-kube-podmaster.sh line 5 ('function' is useless):
function init_templates {
possible bashism in ./magnum/templates/kubernetes/fragments/enable-kube-podmaster.sh line 61 (should be 'b = a'):
    if [ "${TLS_DISABLED}" == "True" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/add-proxy.sh line 19 ($BASH_SOMETHING):
    if [ -f "$BASH_RC" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/add-proxy.sh line 20 ($BASH_SOMETHING):
        echo "declare -x http_proxy=$HTTP_PROXY" >> $BASH_RC
possible bashism in ./magnum/templates/kubernetes/fragments/add-proxy.sh line 22 ($BASH_SOMETHING):
        echo "File $BASH_RC does not exist, not setting http_proxy"
possible bashism in ./magnum/templates/kubernetes/fragments/add-proxy.sh line 27 ($BASH_SOMETHING):
    if [ -f "$BASH_RC" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/add-proxy.sh line 28 ($BASH_SOMETHING):
        echo "declare -x https_proxy=$HTTPS_PROXY" >> $BASH_RC
possible bashism in ./magnum/templates/kubernetes/fragments/add-proxy.sh line 30 ($BASH_SOMETHING):
        echo "File $BASH_RC does not exist, not setting https_proxy"
possible bashism in ./magnum/templates/kubernetes/fragments/add-proxy.sh line 35 ($BASH_SOMETHING):
    if [ -f "$BASH_RC" ]; then
possible bashism in ./magnum/templates/kubernetes/fragments/add-proxy.sh line 36 ($BASH_SOMETHING):
        echo "declare -x no_proxy=$NO_PROXY" >> $BASH_RC
possible bashism in ./magnum/templates/kubernetes/fragments/add-proxy.sh line 38 ($BASH_SOMETHING):
        echo "File $BASH_RC does not exist, not setting no_proxy"
script ./magnum/templates/kubernetes/fragments/disable-selinux.sh does not appear to have a #! interpreter line;
you may get strange results
possible bashism in ./magnum/templates/kubernetes/fragments/configure-docker-storage.sh line 7 (${foo:3[:1]}):
    device_name=$(ls /dev/disk/by-id | grep ${DOCKER_VOLUME:0:20}$)
possible bashism in ./magnum/templates/kubernetes/fragments/configure-docker-storage.sh line 14 (let ...):
    let attempts--
script ./tools/pretty_tox.sh does not appear to be a /bin/sh script; skipping
script ./devstack/plugin.sh does not appear to have a #! interpreter line;
you may get strange results
possible bashism in ./devstack/plugin.sh line 8 (should be '.', not 'source'):
source $DEST/magnum/devstack/lib/magnum
possible bashism in ./devstack/plugin.sh line 12 (alternative test command ([[ foo ]] should be [ foo ])):
    if [[ "$1" == "stack" && "$2" == "install" ]]; then
possible bashism in ./devstack/plugin.sh line 12 (should be 'b = a'):
    if [[ "$1" == "stack" && "$2" == "install" ]]; then
possible bashism in ./devstack/plugin.sh line 17 (alternative test command ([[ foo ]] should be [ foo ])):
        if [[ "$ENABLED_SERVICES" =~ 'm-api' ]]; then
possible bashism in ./devstack/plugin.sh line 19 (should be VAR="${VAR}foo"):
            IMAGE_URLS+=",${MAGNUM_GUEST_IMAGE_URL}"
possible bashism in ./devstack/plugin.sh line 26 (alternative test command ([[ foo ]] should be [ foo ])):
    elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
possible bashism in ./devstack/plugin.sh line 26 (should be 'b = a'):
    elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
possible bashism in ./devstack/plugin.sh line 37 (alternative test command ([[ foo ]] should be [ foo ])):
    elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
possible bashism in ./devstack/plugin.sh line 37 (should be 'b = a'):
    elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
possible bashism in ./devstack/plugin.sh line 49 (alternative test command ([[ foo ]] should be [ foo ])):
    if [[ "$1" == "unstack" ]]; then
possible bashism in ./devstack/plugin.sh line 49 (should be 'b = a'):
    if [[ "$1" == "unstack" ]]; then
possible bashism in ./devstack/plugin.sh line 53 (alternative test command ([[ foo ]] should be [ foo ])):
    if [[ "$1" == "clean" ]]; then
possible bashism in ./devstack/plugin.sh line 53 (should be 'b = a'):
    if [[ "$1" == "clean" ]]; then
$

Shawn Aten (shawnmaten)
Changed in magnum:
assignee: nobody → Shawn Aten (shawnmaten)
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to magnum (master)

Fix proposed to branch: master
Review: https://review.openstack.org/302426

Changed in magnum:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/304845

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/304875

Eli Qiao (taget-9)
Changed in magnum:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to magnum (master)

Reviewed: https://review.openstack.org/304875
Committed: https://git.openstack.org/cgit/openstack/magnum/commit/?id=5be7634e3acde9bd87f109b91a17162e505efd53
Submitter: Jenkins
Branch: master

commit 5be7634e3acde9bd87f109b91a17162e505efd53
Author: Shawn Aten <email address hidden>
Date: Tue Apr 12 21:25:47 2016 +0000

    Fix bashisms found in shell scripts.

    Partial fix for problems output by checkbashisms for file
    magnum/templates/swarm/fragments/configure-docker-storage.sh only.

    Change-Id: I6fc8c789a2b5a1838c0ae98521e236c80a199323
    Partial-Bug: #1561232

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to magnum (master)

Fix proposed to branch: master
Review: https://review.openstack.org/305400

Changed in magnum:
assignee: Shawn Aten (shawnmaten) → hongbin (hongbin034)
Changed in magnum:
assignee: hongbin (hongbin034) → Shawn Aten (shawnmaten)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/305980

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/306005

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to magnum (master)

Reviewed: https://review.openstack.org/304845
Committed: https://git.openstack.org/cgit/openstack/magnum/commit/?id=353d631e70e7c1673568554cd48dbecec1104222
Submitter: Jenkins
Branch: master

commit 353d631e70e7c1673568554cd48dbecec1104222
Author: Shawn Aten <email address hidden>
Date: Tue Apr 12 20:24:39 2016 +0000

    Fix bashisms found in swarm template fragments.

    Partial fix for problems output by checkbashisms for file
    magnum/templates/swarm/fragments/write-docker-service.sh only.

    Quoted variable as recommended.

    Change-Id: Iadcd3435b39ad7bd2575bbf838add1c22b04944f
    Partial-Bug: #1561232

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/305400
Committed: https://git.openstack.org/cgit/openstack/magnum/commit/?id=40b11d24608a82f3842665d7aee5d854668bd706
Submitter: Jenkins
Branch: master

commit 40b11d24608a82f3842665d7aee5d854668bd706
Author: Shawn Aten <email address hidden>
Date: Wed Apr 13 16:42:11 2016 +0000

    Fix bashisms in k8s os config template fragment.

    Partial fix for problems output by checkbashisms for file
    magnum/templates/kubernetes/fragments/write-kube-os-config.sh only.

    Change-Id: I68b021da63b6c2d058053023a4fa26d643f0134b
    Partial-Bug: #1561232

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/305980
Committed: https://git.openstack.org/cgit/openstack/magnum/commit/?id=e57511fffc8febf731d7394bf94636c54512442b
Submitter: Jenkins
Branch: master

commit e57511fffc8febf731d7394bf94636c54512442b
Author: Shawn Aten <email address hidden>
Date: Thu Apr 14 16:51:12 2016 +0000

    Fix bashisms in k8s conf minion template fragment.

    Corrects problems output by checkbashisms in
    magnum/templates/kubernetes/fragments/configure-kubernetes-minion.sh.

    Change-Id: Iedd0ccfdfd3f56514476878c442362a25323be07
    Partial-Bug: #1561232

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on magnum (master)

Change abandoned by Shawn Aten (<email address hidden>) on branch: master
Review: https://review.openstack.org/302426
Reason: As Devstack already requires bash, bashisms in devstack plugin is fine.

Revision history for this message
Shawn Aten (shawnmaten) wrote :

I'm looking for feedback on how to change the following files:

./magnum/templates/mesos/fragments/add-proxy.sh
./magnum/templates/swarm/fragments/add-proxy.sh
./magnum/templates/kubernetes/fragments/add-proxy.sh

The problem is that they echo changes to /etc/bash.bashrc not that they simply contain Bash-specific syntax. I haven't found another system file that could be used for this purpose except /etc/profile but it is not sourced for non-login shells which is how these files would be run.

Further I can't find the variables set in /etc/bash.bashrc by these files (http_proxy, https_proxy, and no_proxy) being used in any other shell scripts. So I'm not sure what the purpose of this code is. I looked for usage with:
grep -E 'http_proxy|https_proxy|no_proxy' `find . -type f -name '*.sh' | grep -vFf skip_files`
The file skip_files contained the files listed above.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Hongbin Lu (<email address hidden>) on branch: master
Review: https://review.openstack.org/306005
Reason: This patch is not able to proceed since Tom gave a -2. I am going to abandon this patch.

Shawn Aten (shawnmaten)
Changed in magnum:
assignee: Shawn Aten (shawnmaten) → nobody
hongbin (hongbin034)
Changed in magnum:
status: In Progress → Fix Committed
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.