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

deprecate unescaped shell special chars in commands #19786

Merged
merged 4 commits into from
Jan 3, 2017

Conversation

StefanKarpinski
Copy link
Member

No description provided.

@StefanKarpinski StefanKarpinski added this to the 0.6.0 milestone Dec 30, 2016
@StefanKarpinski StefanKarpinski added the io Involving the I/O subsystem: libuv, read, write, etc. label Dec 30, 2016

# Julia process with passed in command line flag arguments
cmd = `cd $dir && $tval $exename $exeflags`
cmd = `cd $dir '&&' $tval $exename $exeflags`
Copy link
Contributor

Choose a reason for hiding this comment

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

this is in the ssh code, do we test this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure. @amitmurthy, @tanmaykm?

Copy link
Contributor

@tkelman tkelman Dec 31, 2016

Choose a reason for hiding this comment

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

might be behind the full-tests env var flag? or remote only...

we could add some simple tests that sending quoted/escaped special chars to programs that should be able to use them still act as expected

Copy link
Contributor

Choose a reason for hiding this comment

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

If you wish to test, set JULIA_TESTFULL=1 in your env. Enable password less ssh login into your local machine. Run the parallel test. This will test SSH Manager.

Else I can test this locally in a couple of days.

Copy link
Contributor

Choose a reason for hiding this comment

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

addprocs hangs on the open call with this change. Printing cmd just before the open shows that && is not treated correctly.

`ssh -T -a -x -o ClearAllForwardings=yes -n localhost "sh -l -c \"cd /Users/amitm/Julia/julia '&&' /Users/amitm/Julia/julia/usr/bin/julia --worker ehqbRgqspml7nZLg\""`

@StefanKarpinski StefanKarpinski force-pushed the sk/shellspecial branch 2 times, most recently from fb1fa13 to fc61be6 Compare December 31, 2016 01:58
@tkelman tkelman added the needs news A NEWS entry is required for this change label Dec 31, 2016
@StefanKarpinski
Copy link
Member Author

Ok, @amitmurthy – this seems to work for me locally although the output from make test-parallel with export JULIA_TESTFULL=1 is a bit confusing. Let me know if it looks good to you.


# launch the remote Julia process

# detach launches the command in a new process group, allowing it to outlive
# the initial julia process (Ctrl-C and teardown methods are handled through messages)
# for the launched porcesses.
@show cmd
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

oops, right :)

@amitmurthy
Copy link
Contributor

amitmurthy commented Jan 3, 2017

Yeah, the output prints a few expected errors and one of the reasons it is not part of mainstream CI.

Test passes locally for me too.

Is the Travis error related to this?

A comment/docstring explaining the use of shell_escape would be a welcome addition.

@StefanKarpinski
Copy link
Member Author

The Travis failure is unrelated since I'm seeing it in multiple ongoing PRs. Something recently merged broke 32-bit Linux.

@tkelman
Copy link
Contributor

tkelman commented Jan 3, 2017

agreed it's going to be a bit hard to follow when this needs to be bypassed

@StefanKarpinski
Copy link
Member Author

It's not an exported function. I nevertheless added a docstring. If we have a way of representing pipelines like test whatever && do something then those could print correctly. Currently, we're abusing single-command syntax to pass constructs like that to shells. Hence the confusion.

@tkelman
Copy link
Contributor

tkelman commented Jan 3, 2017

Should these be getting passed as strings instead then in this kind of situation?

@StefanKarpinski
Copy link
Member Author

They could, but that doesn't really address the issue, which is that we don't currently have a way to represent command pipelines. Until we do, which requires a deprecation release cycle, anything we do is a hack. I could change the default for shell_escape to preserve the current behavior, but then command objects with special characters will print in a way that they're not supposed to be input. We could use a different default for commands and arrays of strings, but that just seems more confusing.

@StefanKarpinski
Copy link
Member Author

Let me summarize:

  1. Yes, this escaping situation is a bit confusing.
  2. However, none of these functions is exported from Base.
  3. The non-public behavior is documented in the docstring that's been added.
  4. This situation is temporary: in 1.0 you will be able to write test cond && do thing and it will produce a pipeline object which will print the same way it's input and thus offer a correct and non-confusing way to express this (i.e. this code can go back the way it was).

@tkelman
Copy link
Contributor

tkelman commented Jan 3, 2017

Sure. In this particular case though, the command in question is used as an argument to sh, so unless we implement a full sh parser and semantics, a Julia Cmd isn't the right type for holding argument data.

@StefanKarpinski
Copy link
Member Author

StefanKarpinski commented Jan 3, 2017

We only need enough shell syntax to express the pipeline that's used here, which I do intend to do. If more than that is required, then someone should implement whatever API they want in a package.

@StefanKarpinski StefanKarpinski merged commit 8692b2e into master Jan 3, 2017
@StefanKarpinski StefanKarpinski deleted the sk/shellspecial branch January 3, 2017 14:55
@StefanKarpinski
Copy link
Member Author

Something got messed up here – either I forget to add some of the changes or I just messed this up. More changes are needed and are on their way here.

@tkelman
Copy link
Contributor

tkelman commented Feb 2, 2017

This should leave a todo note in deprecated.jl.

@StefanKarpinski
Copy link
Member Author

About what?

@tkelman
Copy link
Contributor

tkelman commented Feb 2, 2017

That the deprecation should be removed so it doesn't get forgotten. This kind of came out of nowhere in #19598 without a lot of discussion about the future plan, so it should be tracked one way or another.

@StefanKarpinski
Copy link
Member Author

The special characters are going to mean something in 1.0 – namely they're going to construct pipelines, etc. There has been discussion about it previously. No need for a note since this is going to have a new meaning.

@tkelman
Copy link
Contributor

tkelman commented Feb 2, 2017

There has been discussion about it previously

Not that I can recall, any more recently than pipeline was introduced and prior to #19598? There should be a 1.0-milestone issue for it then.

@StefanKarpinski
Copy link
Member Author

StefanKarpinski commented Feb 2, 2017

I've definitely discussed with Jeff, Keno and Jameson but maybe not on GitHub. Issue: #20401.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants