-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix inconsistent parsing of specs from 'spack env' #7743
Fix inconsistent parsing of specs from 'spack env' #7743
Conversation
lib/spack/spack/cmd/env.py
Outdated
@@ -38,10 +38,16 @@ | |||
|
|||
|
|||
def setup_parser(subparser): | |||
subparser.epilog = 'To run a command with the emulated environment' \ | |||
' insert a \'--\' between the spec and the ' \ |
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.
Just wrap the string with " instead of ' and you won't need these backslashes.
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 guess we have conflicting OCDs. Mixing different styles for strings like:
a = 'a string'
b = "another string"
bothers me a bit (in this case more than escaping 2 characters) 😆
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.
In any case, change done!
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.
Oh boy, conflicting OCDs is problematic. Sorry for making you suffer! My logic is that Python allows 2 different string delimiters for a reason, and this is the reason! But OCD doesn't respond to logic well, so that might not help you...
fixes spack#659 Currently the `spack env` command fails if more than one token is given for the spec, like: spack env zlib %gcc This is because the tokens after the first one are interpreted as a command to be executed in the environment. This PR changes the behavior described above to make it more consistent with that of other commands. Now all of the tokens are interpreted as being part of the spec, and if we want to execute a command in the environment we need to separate it from the spec with '--'.
fa99981
to
96b8d82
Compare
@adamjstewart @tgamblin Is the change in behavior fine with you? If so I'll merge the fix. |
@alalazo: is this the best way to do this? |
A solution like that probably involves some more care for the error checking part. For instance, adopting the strategy you propose, with this wrong input: $ spack env zlib szip echo "Hello world!"
==> Error: [Errno 2] No such file or directory we get an error message that is not very informative. Maintaining the OT: where is |
ping |
Any opinion whether this old PR is better to be rebased or closed? |
fixes #659
Currently the
spack env
command fails if more than one token is given for the spec, like:$ spack env zlib %gcc
This is because the tokens after the first one are interpreted as a command to be executed in the environment.
This PR changes the behavior described above to make it more consistent with that of other commands. Now all of the tokens are interpreted as being part of the spec, and if we want to execute a command in the environment we need to separate it from the spec with '--'.