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

shell_(parse|split|escape): fix some issues with deprecation #19985

Merged
merged 2 commits into from
Jan 12, 2017

Conversation

StefanKarpinski
Copy link
Sponsor Member

  • shell_parse needed a special keyword arg but didn't have one
  • seems better to have shell_split and shell_escape default to not having any special shell characters
  • instead the usages of shell_parse in the implementation of the backticks syntax supplies the now-special shell characters and the corresponding use of shell_escape when displaying them too

* shell_parse needed a special keyword arg but didn't have one
* seems better to have shell_split and shell_escape default to
  _not_ having any special shell characters
* instead the usages of shell_parse in the implementation of the
  backticks syntax supplies the now-special shell characters and
  the corresponding use of shell_escape when displaying them too
@StefanKarpinski StefanKarpinski added this to the 0.6.0 milestone Jan 11, 2017
@StefanKarpinski
Copy link
Sponsor Member Author

See #19786. cc: @amitmurthy, @tkelman. This addresses your concerns from that PR by making shell_split and shell_escape default to their old behavior. The usages specifically for Cmd objects and syntax do special = Base.shell_special.


The unexported `shell_escape` function is the inverse of the unexported `shell_split` function:
it takes a string or command object and escapes any special characters in such a way that calling
`shell_split` on it would give back the array of words in the original command. The `special`
keyword argument controls what characters in addition to whitespace, backslashes, quotes and
dollar signs are considered to be special. Examples:
dollar signs are considered to be special (default: none). Examples:
Copy link
Contributor

Choose a reason for hiding this comment

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

"in addition" isn't accurate any more then?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

It is: whitespace, backslashes, quotes and dollar signs are always considered special; the special keyword allows you to supply a string of characters that are also considered special.

@@ -4,7 +4,15 @@

const shell_special = "#{}()[]<>|&*?~;"

function shell_parse(str::AbstractString, interpolate::Bool=true)
# needs to be factored out so depwarn only warns once
@noinline warn_shell_special(special) =
Copy link
Contributor

Choose a reason for hiding this comment

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

why the leading spaces?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

editor playing tricks on me?

@StefanKarpinski StefanKarpinski merged commit 23b04b8 into master Jan 12, 2017
@StefanKarpinski StefanKarpinski deleted the sk/fixshelldep branch January 12, 2017 15:52
@felixrehren felixrehren mentioned this pull request Feb 17, 2017
53 tasks
felixrehren added a commit to felixrehren/julia that referenced this pull request Feb 17, 2017
dollar signs are considered to be special (default: none). Examples:

julia> Base.shell_escape("cat", "/foo/bar baz", "&&", "echo", "done")
"cat '/foo/bar baz' && echo done"

julia> Base.shell_escape("echo", "this", "&&", "that")
"echo this '&&' that"
Copy link
Contributor

@tkelman tkelman May 2, 2017

Choose a reason for hiding this comment

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

no longer displays with quotes around the &&, and these should be doctests so this would have been noticed sooner

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Please make a PR to fix it.

@tkelman tkelman mentioned this pull request May 2, 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
Development

Successfully merging this pull request may close these issues.

2 participants