{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/1136","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/1136/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/1136/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/1136/events","html_url":"https://github.com/JuliaLang/julia/issues/1136","id":6109645,"number":1136,"title":"tilde expansion in path names","user":{"login":"StefanKarpinski","id":153596,"avatar_url":"https://avatars.githubusercontent.com/u/153596?v=3","gravatar_id":"","url":"https://api.github.com/users/StefanKarpinski","html_url":"https://github.com/StefanKarpinski","followers_url":"https://api.github.com/users/StefanKarpinski/followers","following_url":"https://api.github.com/users/StefanKarpinski/following{/other_user}","gists_url":"https://api.github.com/users/StefanKarpinski/gists{/gist_id}","starred_url":"https://api.github.com/users/StefanKarpinski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StefanKarpinski/subscriptions","organizations_url":"https://api.github.com/users/StefanKarpinski/orgs","repos_url":"https://api.github.com/users/StefanKarpinski/repos","events_url":"https://api.github.com/users/StefanKarpinski/events{/privacy}","received_events_url":"https://api.github.com/users/StefanKarpinski/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/decision","name":"decision","color":"F08000"},{"url":"https://api.github.com/repos/JuliaLang/julia/labels/up%20for%20grabs","name":"up for grabs","color":"0b02e1"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/JuliaLang/julia/milestones/8","html_url":"https://github.com/JuliaLang/julia/milestones/0.4.x","labels_url":"https://api.github.com/repos/JuliaLang/julia/milestones/8/labels","id":303801,"number":8,"title":"0.4.x","description":"Bugs that should be fixed within the 0.4.x series. Can be fixed for 0.4 as well, but do not block the 0.4 release.","creator":{"login":"vtjnash","id":330950,"avatar_url":"https://avatars.githubusercontent.com/u/330950?v=3","gravatar_id":"","url":"https://api.github.com/users/vtjnash","html_url":"https://github.com/vtjnash","followers_url":"https://api.github.com/users/vtjnash/followers","following_url":"https://api.github.com/users/vtjnash/following{/other_user}","gists_url":"https://api.github.com/users/vtjnash/gists{/gist_id}","starred_url":"https://api.github.com/users/vtjnash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vtjnash/subscriptions","organizations_url":"https://api.github.com/users/vtjnash/orgs","repos_url":"https://api.github.com/users/vtjnash/repos","events_url":"https://api.github.com/users/vtjnash/events{/privacy}","received_events_url":"https://api.github.com/users/vtjnash/received_events","type":"User","site_admin":false},"open_issues":72,"closed_issues":94,"state":"open","created_at":"2013-04-05T16:15:28Z","updated_at":"2015-07-31T07:38:08Z","due_on":null,"closed_at":null},"comments":17,"created_at":"2012-08-08T18:21:42Z","updated_at":"2015-07-31T07:42:02Z","closed_at":null,"body":"@timholy implemented `tilde_expand` (see [file.jl](https://github.com/JuliaLang/julia/blob/master/base/file.jl#L99)) some time ago and it is now used automatically by a few file-system commands, notably `cd()`. This concerns me, however, since while it's convenient for some things, it's inconsistently used, and it violates the treatment of strings as just data. What if the name of a file is just `~`? We're now in a position where that name needs to be escaped and handled specially in code. On the other hand, tilde expansion is awfully handy.\n\nSo here's a possibility: bake tilde expansion into the backtick syntax instead. For example, we could make this work:\n\n```julia\njulia> run(`tail ~/.julia_history`)\n           error(\"~user tilde expansion not yet implemented\")\n       end\ntilde_expand(\"~\")\ntilde_expand(\"~/foo\")\ntilde_expand(\"~stefan/foo\")\ntilde_expand(\"~stefan\")\n`cat ~/.julia`\nrun(`cat ~/.julia`)\nrun(`tail ~/.julia_history`)\nrun(`tail $(ENV[\"HOME\"])/.julia_history`)\n```\n\nCurrently this just looks for a file literally named `~/.julia_history`. Obviously, this would be handy for entering commands, but you could also use it in situations where you want shell-like treatment of any string. For example `` cd(`~`) `` would expand to `cd(ENV[\"HOME\"])` whereas `cd(\"~\")` would treat its argument literally. Very importantly, tilde expansion would be done at compile time, not based on the run-time data — this is essential to avoiding nasty surprises and corner cases. In particular, interpolated values are not tilde expanded:\n\n```julia\njulia> `~`\n`/Users/stefan`\n\njulia> file = \"~\";\n\njulia> `$file`\n`~`\n```\n\nOne corollary of this approach is that file and directory operations have to work with `Cmd` objects, which maybe ought to be renamed in light of their broadened use-cases under this proposal. Maybe they should be called `ShellString` objects since backtick strings are basically strings with shell-like behavior. Except that they're also not strings, so maybe that's not a great name either."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/126594446","html_url":"https://github.com/JuliaLang/julia/issues/1136#issuecomment-126594446","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/1136","id":126594446,"user":{"login":"vtjnash","id":330950,"avatar_url":"https://avatars.githubusercontent.com/u/330950?v=3","gravatar_id":"","url":"https://api.github.com/users/vtjnash","html_url":"https://github.com/vtjnash","followers_url":"https://api.github.com/users/vtjnash/followers","following_url":"https://api.github.com/users/vtjnash/following{/other_user}","gists_url":"https://api.github.com/users/vtjnash/gists{/gist_id}","starred_url":"https://api.github.com/users/vtjnash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vtjnash/subscriptions","organizations_url":"https://api.github.com/users/vtjnash/orgs","repos_url":"https://api.github.com/users/vtjnash/repos","events_url":"https://api.github.com/users/vtjnash/events{/privacy}","received_events_url":"https://api.github.com/users/vtjnash/received_events","type":"User","site_admin":false},"created_at":"2015-07-31T07:42:02Z","updated_at":"2015-07-31T07:42:02Z","body":"since homedir support landed recently in libuv (https://github.com/libuv/libuv/pull/350), we may want to consider switching over to that once https://github.com/JuliaLang/julia/pull/12266 is merged"}}