{"action":"created","issue":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/3596","repository_url":"https://api.github.com/repos/fish-shell/fish-shell","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/3596/labels{/name}","comments_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/3596/comments","events_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/3596/events","html_url":"https://github.com/fish-shell/fish-shell/pull/3596","id":191902633,"number":3596,"title":"Allow variable expansion and command substitution on decorated statements in command position","user":{"login":"floam","id":291142,"avatar_url":"https://avatars.githubusercontent.com/u/291142?v=3","gravatar_id":"","url":"https://api.github.com/users/floam","html_url":"https://github.com/floam","followers_url":"https://api.github.com/users/floam/followers","following_url":"https://api.github.com/users/floam/following{/other_user}","gists_url":"https://api.github.com/users/floam/gists{/gist_id}","starred_url":"https://api.github.com/users/floam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floam/subscriptions","organizations_url":"https://api.github.com/users/floam/orgs","repos_url":"https://api.github.com/users/floam/repos","events_url":"https://api.github.com/users/floam/events{/privacy}","received_events_url":"https://api.github.com/users/floam/received_events","type":"User","site_admin":false},"labels":[{"id":4724778,"url":"https://api.github.com/repos/fish-shell/fish-shell/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":278051545,"url":"https://api.github.com/repos/fish-shell/fish-shell/labels/release-notes","name":"release-notes","color":"bfdadc","default":false}],"state":"open","locked":false,"assignee":{"login":"floam","id":291142,"avatar_url":"https://avatars.githubusercontent.com/u/291142?v=3","gravatar_id":"","url":"https://api.github.com/users/floam","html_url":"https://github.com/floam","followers_url":"https://api.github.com/users/floam/followers","following_url":"https://api.github.com/users/floam/following{/other_user}","gists_url":"https://api.github.com/users/floam/gists{/gist_id}","starred_url":"https://api.github.com/users/floam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floam/subscriptions","organizations_url":"https://api.github.com/users/floam/orgs","repos_url":"https://api.github.com/users/floam/repos","events_url":"https://api.github.com/users/floam/events{/privacy}","received_events_url":"https://api.github.com/users/floam/received_events","type":"User","site_admin":false},"assignees":[{"login":"floam","id":291142,"avatar_url":"https://avatars.githubusercontent.com/u/291142?v=3","gravatar_id":"","url":"https://api.github.com/users/floam","html_url":"https://github.com/floam","followers_url":"https://api.github.com/users/floam/followers","following_url":"https://api.github.com/users/floam/following{/other_user}","gists_url":"https://api.github.com/users/floam/gists{/gist_id}","starred_url":"https://api.github.com/users/floam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floam/subscriptions","organizations_url":"https://api.github.com/users/floam/orgs","repos_url":"https://api.github.com/users/floam/repos","events_url":"https://api.github.com/users/floam/events{/privacy}","received_events_url":"https://api.github.com/users/floam/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/fish-shell/fish-shell/milestones/13","html_url":"https://github.com/fish-shell/fish-shell/milestone/13","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/milestones/13/labels","id":1624432,"number":13,"title":"fish 2.5.0","description":"next release in the 2.x series (minor releases)\r\nin general, no backward incompatible changes should be accepted for this release","creator":{"login":"zanchey","id":520741,"avatar_url":"https://avatars.githubusercontent.com/u/520741?v=3","gravatar_id":"","url":"https://api.github.com/users/zanchey","html_url":"https://github.com/zanchey","followers_url":"https://api.github.com/users/zanchey/followers","following_url":"https://api.github.com/users/zanchey/following{/other_user}","gists_url":"https://api.github.com/users/zanchey/gists{/gist_id}","starred_url":"https://api.github.com/users/zanchey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zanchey/subscriptions","organizations_url":"https://api.github.com/users/zanchey/orgs","repos_url":"https://api.github.com/users/zanchey/repos","events_url":"https://api.github.com/users/zanchey/events{/privacy}","received_events_url":"https://api.github.com/users/zanchey/received_events","type":"User","site_admin":false},"open_issues":42,"closed_issues":101,"state":"open","created_at":"2016-03-06T13:32:50Z","updated_at":"2016-12-29T23:57:01Z","due_on":"2017-01-08T08:00:00Z","closed_at":null},"comments":5,"created_at":"2016-11-28T01:43:03Z","updated_at":"2016-12-30T03:42:22Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/fish-shell/fish-shell/pulls/3596","html_url":"https://github.com/fish-shell/fish-shell/pull/3596","diff_url":"https://github.com/fish-shell/fish-shell/pull/3596.diff","patch_url":"https://github.com/fish-shell/fish-shell/pull/3596.patch"},"body":"This allows variable substituion for the argument-like commands given to\r\nbuiltin, command, and exec, intended to obviate uses of `eval`.\r\n\r\nFixes #154.\r\n\r\nReposted from #3595:\r\n\r\nI think on the whole we are very happy not expanding variables in the command position in fish. But why does the parser not allow variables to expand when used as arguments for builtins like command? The rules are rather strange and handed on down from the parser with these.\r\n\r\nPresently\r\n=======\r\n\r\nIt's hard to understand why this works: `set -l prefix /usr/local/bin/; ls \"$prefix/fish\"`\r\nBut not:\r\n```\r\n$ set -l prefix /usr/local/bin/; exec \"$prefix/fish\"\r\nVariables may not be used as commands. In fish, please define a function or use 'eval \"$path/fish\"'.\r\n```\r\n\r\nIt's inconsistent.\r\n\r\nThe \"solution\" is `eval`, but the `eval` function can be terribly difficult to use effectively or safely. We should never be suggesting this for mundane tasks. We have code like this, that only had the string escape thing added recently because nobody on the team noticed \"Fish 2.3.0.app\" in the data directory path will break it:\r\n`eval (string escape $__fish_datadir/tools/web_config/webconfig.py) $initial_tab`\r\n\r\nBecause of hard-to-understand stuff happening with quoting, escaping, spaces, I doubt most people would happen upon a correct, good way to use `eval` without a lot of trial and error.\r\n\r\n`$fish_datadir/tools/web_config/webconfig.py`shouldn't be a valid command, but what if we allow this: `command \"$fish_datadir/tools/web_config/webconfig.py\"`?\r\n\r\nProof of concept\r\n=============\r\n\r\nI've been using fish with a simple change to the parser for a while and I think it's a great improvement. I simply allow variable expansion on commands, only decorated ones, like command foo, builtin foo, exec foo, not undecorated naked commands such as \"foo\".\r\n\r\n*patch snipped* -- see PR commits\r\n```\r\n$ uname\r\nDarwin\r\n$ command $history[1]\r\nDarwin\r\n$ set foo ls\r\n$ command $foo /\r\nApplications\t\t\tbin\t\t\t\tnet\r\nDeveloper\t\t\tcores\t\t\t\tprivate\r\nLibrary\t\t\t\tdev\t\t\t\tsbin\r\nNetwork\t\t\t\tetc\t\t\t\ttest\r\nSystem\t\t\t\thome\t\t\t\ttmp\r\nUsers\t\t\t\tinstaller.failurerequests\tusr\r\nVolumes\t\t\t\tkeybase\t\t\t\tvar\r\n$ command $foo /cores\r\nloginwindow-120-20160913T174108Z\tloginwindow-120-20160913T174317Z\tloginwindow-120-20160913T174334Z\r\n$ $foo / # still not allowed\r\nVariables may not be used as commands. In fish, please define a function or use 'eval $foo'.\r\n```\r\nSpaces:\r\n```\r\n$ set foo \"echo hi\" # this isn't a valid command name\r\n$ command $foo there\r\nfish: Unknown command 'echo hi'\r\nfish: command $foo there\r\n```\r\nversus eval:\r\n```\r\n$ set __fish_bin_dir ~/Downloads/fish\\ 2.app/Contents/Resources/base/bin/\r\n$ eval \"$__fish_bin_dir/fish\" -v\r\nfish: Unknown command '/Users/floam/Downloads/fish'\r\n$ command \"$__fish_bin_dir/fish\" -v\r\nfish, version 2.3.0\r\n```\r\n\r\nShould we also expand command substitutions?"},"comment":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/comments/269728468","html_url":"https://github.com/fish-shell/fish-shell/pull/3596#issuecomment-269728468","issue_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/3596","id":269728468,"user":{"login":"ridiculousfish","id":920838,"avatar_url":"https://avatars.githubusercontent.com/u/920838?v=3","gravatar_id":"","url":"https://api.github.com/users/ridiculousfish","html_url":"https://github.com/ridiculousfish","followers_url":"https://api.github.com/users/ridiculousfish/followers","following_url":"https://api.github.com/users/ridiculousfish/following{/other_user}","gists_url":"https://api.github.com/users/ridiculousfish/gists{/gist_id}","starred_url":"https://api.github.com/users/ridiculousfish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ridiculousfish/subscriptions","organizations_url":"https://api.github.com/users/ridiculousfish/orgs","repos_url":"https://api.github.com/users/ridiculousfish/repos","events_url":"https://api.github.com/users/ridiculousfish/events{/privacy}","received_events_url":"https://api.github.com/users/ridiculousfish/received_events","type":"User","site_admin":false},"created_at":"2016-12-30T03:42:22Z","updated_at":"2016-12-30T03:42:22Z","body":"@krader1961 Do I understand your proposal correctly, that:\r\n\r\n1. Decorations like command, builtin, and exec will expand their arguments\r\n2. You would like to introduce a `call` function that will run the command/builtin/function after expanding its argument?"}}
{"actor":{"display_login":"ridiculousfish"}}