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

scope launch script improvements #2077

Merged
merged 8 commits into from
Dec 12, 2016
Merged

Conversation

ekimekim
Copy link
Contributor

@ekimekim ekimekim commented Dec 9, 2016

  • fix linter issues
  • make some attempt at correct quoting in scope command when available
  • fix and rewrite usage/help text for clarity and extra info
  • don't print container id as it's confusing when presented out of context, and rarely useful

See individual commits for discussion on each point.

Fixes #2073. Fixes #1556. Fixes #1557. Fixes #1560.

@ekimekim ekimekim force-pushed the mike/scope-script/shellcheck branch from 565f499 to 82270b0 Compare December 9, 2016 15:23
@rade
Copy link
Member

rade commented Dec 9, 2016

This fixes #2073, right? And perhaps some others?

@ekimekim
Copy link
Contributor Author

ekimekim commented Dec 9, 2016

yes, sorry. I edited to mention that between you loading and you commenting.
I reviewed other open issues, I'd say this also fixes #1556 which was practically a duplicate, but nothing else.

@ekimekim
Copy link
Contributor Author

ekimekim commented Dec 9, 2016

Slightly changed the wording to properly fix #1556

@ekimekim
Copy link
Contributor Author

ekimekim commented Dec 9, 2016

Also now fixes #1557 and #1560. #1560 partially addresses #1562

Copy link
Contributor

@jml jml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

I think there are a couple of open tickets in Scope that this might fix. Would you mind taking a quick look & linking them before merging? Best effort is fine.

# TODO: properly escape/quote the output of "$@"
echo $(launch_command) "$@"
# Most systems should have printf, but the %q specifier isn't mandated by posix
# and can't be guarenteed. Since this is mainly a cosmetic output and the alternative

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

By far the majority of these were variables which were not quoted.
While, yes, right now we can guarentee most of these variables will never contain spaces,
this could someday change and applying quoting as a universal rule prevents future mistakes.

The ARGS="$@" -> "$*" change is purely stylistic and mainly is used to indicate the intent that
we actually wanted to concatenate all the args by spaces, not keep them seperated as "$@" would
in many situations, but not this one.

Several warnings remain, in places where we intentionally want to split a variable on whitespace,
or otherwise do what shellcheck is warning us against.

Of note is shellcheck warning SC2166, which says to prefer [ foo ] || [ bar ] over [ foo -o bar ]
as the -a and -o flags have differing behaviour on some systems.
I've opted to keep these for now, since the version check test command would need to be replaced by
a LOT of subshells to achieve the same effect, which feels dirtier.
As indicated by the TODO, any args passed into the command do not get escaped
when output, so for example:
	scope command "foo bar"
would output results like:
	foo bar
instead of
	"foo bar"
or
	foo\ bar

The "right" way to do this seems to be printf %q, which prints a quoted version of the string.
However this format specifier is not available in POSIX sh (though it does work in many
implementations of it, such as the ones provided by bash which make up the likely majority of
real-world usage).
This code is a compromise that uses the added functionality where available,
while still falling back to the old behaviour when it isn't.
Instead of different usage info for "scope help", show the same always.
Also correct it for what the script actually does,
and always display the scope binary args.
It's not useful and it's confusing.
Replaced with a generic "it worked" message.
… worked

We can't easily do this since scope exits failure when -h is passed, so we
can't distinugish between success and failure.
@ekimekim ekimekim force-pushed the mike/scope-script/shellcheck branch from 17e83ff to 2562567 Compare December 12, 2016 19:26
@ekimekim ekimekim merged commit bbcf184 into master Dec 12, 2016
@ekimekim ekimekim deleted the mike/scope-script/shellcheck branch December 12, 2016 22:31
@ekimekim ekimekim mentioned this pull request Jan 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants