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

correct posixly shell quoting #23881

Merged
merged 1 commit into from
Oct 24, 2017
Merged

correct posixly shell quoting #23881

merged 1 commit into from
Oct 24, 2017

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Sep 26, 2017

Ensures that addprocs arguments will be passed through a posix shell correctly, (including those with shell-metacharacters such as being added in #21849 for -C, but also weird cases like -- and files named \r).

fix #10120

@vtjnash vtjnash added bugfix This change fixes an existing bug REPL Julia's REPL (Read Eval Print Loop) labels Sep 26, 2017
@yuyichao
Copy link
Contributor

You do make me wonder if I should have chosen another character instead.
OTOH though, , is what llvm use for features so I'd like to keep that, / is a bit strange since it usually mean nesting (path) which this isn't, : looks similar to ; but it feel like a lower evel of separation than ,........................

@vtjnash
Copy link
Member Author

vtjnash commented Sep 26, 2017

You do make me wonder if I should have chosen another character instead.

This was not the motivation for the PR, I just thought it would be interesting to note current known cases that this fixes (passing other exeflags is usually pretty rare, as is having shell metacharacters in the path).

@yuyichao
Copy link
Contributor

This was not the motivation for the PR

Yes, I know. I just wonder if this can cause other random script to error. Though this is just a compile flag so you normally won't use it in a script or addproc.

@vtjnash vtjnash force-pushed the jn/shell_escape_posixly branch from 2653f57 to f8262f3 Compare September 26, 2017 20:05
# @test contains(s, "echo hello >/dev/null") # make sure we echoed the input
# end
# @test readuntil(stdout_read, "\n") == "\e[0m\n"
#end
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: these disabled tests are left as motivation for someone to finish the implementation of #20401 🙂

Copy link
Member

Choose a reason for hiding this comment

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

Do these tests not pass anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

With the current deprecation, they're partially broken. Hence the motivation for someone to remove the deprecation and finish implementing the #20401

@StefanKarpinski
Copy link
Member

Would it be possible to just make shell_escape POSIX-compatible by default? If so, I think we should just do that since it seems good to just default to shell escaping in a way that works in POSIX shells.

@vtjnash
Copy link
Member Author

vtjnash commented Sep 27, 2017

Would it be possible to just make shell_escape POSIX-compatible by default?

Perhaps, since I think currently shell_parse will get the same result when called on the result of shell_escape_posixly (that's partially of the idea of the function - to be an overly conservatively approximation of all shells). I don't think there's any particular reason to remove shell_escape however, since it's useful for its intended purpose (as a pretty-printer for Cmd objects), and I'm not sure what #20401 will want for changes to the parser.

@vtjnash
Copy link
Member Author

vtjnash commented Sep 29, 2017

since I think currently shell_parse will get the same result

Actually, this isn't true, but upon further review, I think it may actually be due to other bugs in shell_escape, rather than being due to divergence between shell_parse and posix sh:

julia> Base.shell_escape(` '$a"' `)
"'\$a\"'"

julia> Base.shell_escape(` '\$a\"' `)
"'\\\$a\\\"'"

ensures that arguments will be passed through a posix shell correctly,
(including those such as being added in #21849 for -C)

fix #10120
@vtjnash vtjnash force-pushed the jn/shell_escape_posixly branch from f8262f3 to ef47e60 Compare October 12, 2017 16:44
@vtjnash vtjnash merged commit de9991e into master Oct 24, 2017
@vtjnash vtjnash deleted the jn/shell_escape_posixly branch October 24, 2017 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REPL shell mode calls the shell with incorrectly escaped arguments
4 participants