Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues 78 - Makes install.sh more shellcheck compliant. #81

Merged
merged 9 commits into from
Apr 3, 2017

Conversation

Potherca
Copy link
Member

@Potherca Potherca commented Apr 2, 2017

Introduction

I was thinking about taking a stab at #53 but decided to make the relevant file more shellcheck compliant first (as suggested in issue #78).

Suggested Changes

Shellcheck Fixes

All occurrences of the following issues have been resolved:

  • SC1054: You need a space after the '{'.
  • SC2004: $ on variables in (( )) is unnecessary.
  • SC2034: "variable" appears unused. Verify it or export it.
  • SC2046: Quote this to prevent word splitting.
  • SC2068: Double quote array expansions, otherwise they're like $* and break on spaces.
  • SC2086: Double quote to prevent globbing and word splitting.
  • SC2116: Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.

Other issues

Whilst resolving shellcheck issues, I ran into two problems.

  1. The call curl "${auth_param}" caused trouble when auth_param is empty (=''). This did not happen when there were no quotes around auth_param, that is to say, things accidentally worked.
    To resolve this I added a wrapper for the three use-cases around curl with a check and two variations of calling curl (one with and one without auth_param.
  2. In some edge-cases the -o /dev/null will fail with a write error (curl error 23). However, failure to write to /dev/null is not an issue, as the HTTP status code is still viable. To resolve this I added a separate function for the "check url exists" logic and added the check there.

If these two solutions do not cause any trouble, I do believe they are worth keeping as they are a good first step in de-duplicating some of the curl calls.

Work for later

The following shellcheck issues are still present as I am unsure as how to resolve them:

  • SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
  • SC2030: Modification of script is local (to subshell caused by (..) group).
  • SC2031: script was modified in a subshell. That change might be lost.

I would suggest fixing those issues in a separate PR to keep things moving.

I'll continue work on #53 on a separate branch and open a PR once this has been merged to master.

@Potherca Potherca changed the title Issues 78 - Makes install.sh more shellcheck compliant. [WIP] Issues 78 - Makes install.sh more shellcheck compliant. Apr 2, 2017
@Potherca Potherca changed the title [WIP] Issues 78 - Makes install.sh more shellcheck compliant. Issues 78 - Makes install.sh more shellcheck compliant. Apr 3, 2017
@Potherca Potherca mentioned this pull request Apr 3, 2017
@jwerle
Copy link
Member

jwerle commented Apr 3, 2017

@Potherca thank you for this!

@jwerle
Copy link
Member

jwerle commented Apr 3, 2017

Is this PR safe to merge in? Do you have anything else you'd like to add to it?

@Potherca
Copy link
Member Author

Potherca commented Apr 3, 2017

I didn't feel too sure about the "gurl" curl wrapper so I cleaned that up by having two variations per function (wrapper) using curl.

Everything should be good to merge now.

@jwerle
Copy link
Member

jwerle commented Apr 3, 2017

@Potherca awesome thanks!!

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

Successfully merging this pull request may close these issues.

2 participants