-
Notifications
You must be signed in to change notification settings - Fork 90
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
Login shell #149
Login shell #149
Conversation
This is to address #148 |
@jonathanmorley It a great idea to support the login shell. By default, I would expect that train would run in a |
This change keeps the default behaviour of train (the |
def build_prefix | ||
return '' unless @sudo | ||
return '' if @user == 'root' | ||
def sudo_wrap(cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add comments what these function do
@@ -29,6 +29,8 @@ class LinuxCommand < CommandWrapperBase | |||
Train::Options.attach(self) | |||
|
|||
option :sudo, default: false | |||
option :shell, default: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its a little bit sub-optimal to switch types of a variable, I would prefer nil
here, which would lead to the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also lets add a comment to give users an idea of potential values
def shell_wrap(cmd) | ||
return cmd unless @shell || @login | ||
login_param = '--login ' if @login | ||
shell = @shell.instance_of?(String) ? @shell : '$SHELL' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not to check for the type here
Great idea 👍 |
@@ -69,3 +69,5 @@ Style/SpaceAroundOperators: | |||
Enabled: false | |||
Style/IfUnlessModifier: | |||
Enabled: false | |||
Style/FrozenStringLiteralComment: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing the default setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because we don't yet have frozen string literal comments in our files:
http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/FrozenStringLiteralComment
I think it's ok to disable for now and let's tackle this in a rubocop cleanup session 😄
@jonathanmorley Thanks for incorporating my comments. Could you fix the functional test?
|
Fixed. One remaining concern I have here is over quotes in the cmd. I have wrapped the cmd in single quotes so that the outer shell doesn't parse out any special characters, and through testing of things like
It seems to work as intended. However, I see that for sudo we use base64 encoding. Any preferences between the 2 approaches? |
Thanks for bringing up the question @jonathanmorley base64 proofed to be very reliant so far, therefore I would prefer that solution... |
💯 Thanks @jonathanmorley for this improvement! This travis errors are caused by docker timeouts not related to this PR |
Add
login
andshell
options, to be able to force the command to run in a login shell