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

Also complete commands (files in the env path) in REPL shell mode #12307

Merged
merged 1 commit into from
Nov 10, 2015

Conversation

mariushoch
Copy link
Contributor

Tested on Fedora only.

@tkelman tkelman added the REPL Julia's REPL (Read Eval Print Loop) label Jul 25, 2015
@@ -109,7 +109,7 @@ function complete_keyword(s::ByteString)
sorted_keywords[r]
end

function complete_path(path::AbstractString, pos)
function complete_path(path::AbstractString, pos, use_envpath)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would be better as a keyword argument rather than positional

@mariushoch
Copy link
Contributor Author

Addressed comments by @tkelman … thanks.

@mariushoch
Copy link
Contributor Author

rebased

let
oldpath = ENV["PATH"]
ENV["PATH"] = homedir()
file = joinpath(path, "tmp-executable")
Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming you are copying the block above, I think the path should be homedir().

You also don't need to do this in the home directory, #11440 need it because it is testing the ~ expansion. (Although a hidden and random directory might be better @blakejohnson ). You should use a tempdir for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

@yuyichao I was thinking I should at least revise the test I added to cleanup on failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not using the homedir makes sense. Changed.

@mariushoch
Copy link
Contributor Author

Any chance someone could have a look at this again?

@tkelman
Copy link
Contributor

tkelman commented Aug 25, 2015

kind of feature-ish to merge this right now, would be better to wait until we've branched so any potential issues can be addressed with less time pressure

@StefanKarpinski
Copy link
Member

Yeah, let's merge after 0.4 and then mark it as eligible for backporting since it's purely interactive.

@mariushoch
Copy link
Contributor Author

Thanks for the heads up, that sounds good to me.

@tkelman
Copy link
Contributor

tkelman commented Sep 9, 2015

Master's open again and we've branched, so I guess this is okay to merge and we can target to backport it for 0.4.1. Maybe prior to that, but would prefer this get a fair amount of testing on master first.

@hayd hayd added this to the 0.4.1 milestone Sep 23, 2015
@tkelman
Copy link
Contributor

tkelman commented Nov 1, 2015

Anyone familiar with the repl completions code have an opinion here?

@blakejohnson
Copy link
Contributor

LGTM

local filesinpath = readdir(pathdir)

for file in filesinpath
if startswith(file, prefix) && isexecutable(joinpath(pathdir, file))
Copy link
Contributor

Choose a reason for hiding this comment

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

oh, I think isexecutable is likely to be deprecated soon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you (offhand) tell me what to use instead? If so, I'll amend this… otherwise, this can still be done later easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked for that and it is pending merge (#12819).

Copy link
Contributor

Choose a reason for hiding this comment

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

isfile is probably the most appropriate choice for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about that, there might be non executable files in PATH. In a perfect world, we would also filter based on whether the current user is able to execute the file in question (like bash does), but I don't see a nice way to do that (latest bash uses glibc's eaccess or access if available, otherwise it tries to figure on its own).
Implementing something like that might be something we want to do in a follow up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Completing on non-executable files isn't the end of the world. That function is about to be deprecated, so we can't be adding uses of it in base.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough, I'll amend this patch and add a note.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it could be filtered on file mode, but maybe leave that for a second round.

@tkelman tkelman modified the milestones: 0.4.2, 0.4.1 Nov 9, 2015
@mariushoch
Copy link
Contributor Author

Amended to no longer use the soon to be deprecated isexecutable.

tkelman added a commit that referenced this pull request Nov 10, 2015
Also complete commands (files in the env path) in REPL shell mode
@tkelman tkelman merged commit 28cd3c7 into JuliaLang:master Nov 10, 2015
@mariushoch
Copy link
Contributor Author

This breaks in case a user has something in their path which they can't actual read. #13959 will fix that.

tkelman pushed a commit that referenced this pull request Nov 29, 2015
Tested on Fedora only.

(cherry picked from commit 5b12348)
ref #12307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants