Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

shellcheck #85

Open
michaelwittig opened this issue Aug 29, 2017 · 2 comments
Open

shellcheck #85

michaelwittig opened this issue Aug 29, 2017 · 2 comments
Labels

Comments

@michaelwittig
Copy link
Contributor

Hi,

I would like to add a tool called shellcheck to lint shell scripts before we merge them into master.

At the moment, the tool finds toe following issues:

$ find . -type f -name '*.sh' -exec shellcheck -s bash {} \;

In ./authorized_keys_command.sh line 8:
[ -f /etc/aws-ec2-ssh.conf ] && . /etc/aws-ec2-ssh.conf
                                ^-- SC1091: Not following: /etc/aws-ec2-ssh.conf was not specified as input (see shellcheck -x).


In ./authorized_keys_command.sh line 13:
: ${ASSUMEROLE:=""}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 4:
[ -f /etc/aws-ec2-ssh.conf ] && . /etc/aws-ec2-ssh.conf
                                ^-- SC1091: Not following: /etc/aws-ec2-ssh.conf was not specified as input (see shellcheck -x).


In ./import_users.sh line 7:
: ${DONOTSYNC:=0}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 17:
: ${IAM_AUTHORIZED_GROUPS:=""}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 20:
: ${LOCAL_MARKER_GROUP:="iam-synced-users"}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 23:
: ${LOCAL_GROUPS:=""}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 29:
: ${SUDOERSGROUP:=""}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 34:
: ${SUDOERS_GROUPS:="${SUDOERSGROUP}"}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 39:
: ${ASSUMEROLE:=""}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 42:
: ${USERADD_PROGRAM:="/usr/sbin/useradd"}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 45:
: ${USERADD_ARGS:="--create-home --shell /bin/bash"}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 78:
            aws --region $REGION ec2 describe-tags \
                         ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 95:
        for group in $(echo ${IAM_AUTHORIZED_GROUPS} | tr "," " "); do
                            ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 126:
            aws --region $REGION ec2 describe-tags \
                         ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 166:
    if [[ ! "${username}" =~ ^[0-9a-zA-Z\._\-]{1,32}$ ]]
                                           ^-- SC1001: This \- will be a regular '-' in this context.


In ./import_users.sh line 178:
        ${USERADD_PROGRAM} ${USERADD_ARGS} "${username}"
                           ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 179:
        /bin/chown -R "${username}:${username}" "$(eval echo ~$username)"
                                                              ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 250:
    intersection=$(echo ${local_users} ${iam_users} | tr " " "\n" | sort | uniq -D | uniq)
                        ^-- SC2086: Double quote to prevent globbing and word splitting.
                                       ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 251:
    removed_users=$(echo ${local_users} ${intersection} | tr " " "\n" | sort | uniq -u)
                         ^-- SC2086: Double quote to prevent globbing and word splitting.
                                        ^-- SC2086: Double quote to prevent globbing and word splitting.

If there are no doubts, I would like to activate the tool and I would also fix the existing findings.

@artburkart
Copy link

artburkart commented Jun 27, 2018

Oh, I wish I'd noticed this sooner. I'm all about it. I'm happy to make a PR too, if you'd like.

@michaelwittig
Copy link
Contributor Author

I believe it would add value. Catch as many issued as possible with linting.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants