{"action":"created","issue":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2394","repository_url":"https://api.github.com/repos/fish-shell/fish-shell","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2394/labels{/name}","comments_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2394/comments","events_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2394/events","html_url":"https://github.com/fish-shell/fish-shell/issues/2394","id":106717801,"number":2394,"title":"Failed wildcards still execute","user":{"login":"fizzfaldt","id":2748321,"avatar_url":"https://avatars.githubusercontent.com/u/2748321?v=3","gravatar_id":"","url":"https://api.github.com/users/fizzfaldt","html_url":"https://github.com/fizzfaldt","followers_url":"https://api.github.com/users/fizzfaldt/followers","following_url":"https://api.github.com/users/fizzfaldt/following{/other_user}","gists_url":"https://api.github.com/users/fizzfaldt/gists{/gist_id}","starred_url":"https://api.github.com/users/fizzfaldt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fizzfaldt/subscriptions","organizations_url":"https://api.github.com/users/fizzfaldt/orgs","repos_url":"https://api.github.com/users/fizzfaldt/repos","events_url":"https://api.github.com/users/fizzfaldt/events{/privacy}","received_events_url":"https://api.github.com/users/fizzfaldt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/fish-shell/fish-shell/milestones/12","html_url":"https://github.com/fish-shell/fish-shell/milestones/next-2.x","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/milestones/12/labels","id":1066419,"number":12,"title":"next-2.x","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":30,"closed_issues":232,"state":"open","created_at":"2015-04-14T07:44:05Z","updated_at":"2016-02-09T00:05:43Z","due_on":null,"closed_at":null},"comments":16,"created_at":"2015-09-16T07:44:20Z","updated_at":"2016-02-09T04:49:34Z","closed_at":null,"body":"From the documentation:\r\nhttp://fishshell.com/docs/current/#expand-wildcard\r\n> If none of the wildcarded arguments sent to a command result in any matches, the command will not be executed. If this happens when using the shell interactively, a warning will also be printed.\r\nIt still gets executed after being deleted.\r\nThis used to work for me, it might be related to my fish version.\r\n\r\n```\r\nfizzfaldt@buk ~/fishtest> fish --version\r\nfish, version 2.2.0\r\nfizzfaldt@buk ~/fishtest> dpkg -l | grep fish\r\nii  fish                                                        2.2.0-1~trusty                                      amd64        friendly interactive shell\r\n```\r\n\r\nCreate a directory containing \"foo\" and \"bar\"\r\n```\r\nfizzfaldt@buk ~/fishtest> command /bin/ls -1 -l\r\ntotal 0\r\n-rw-rw-r-- 1 fizzfaldt fizzfaldt 0 Sep 16 00:38 bar\r\n-rw-rw-r-- 1 fizzfaldt fizzfaldt 0 Sep 16 00:38 foo\r\n```\r\n> If none of the wildcarded arguments sent to a command result in any matches, the command will not be executed.\r\n\r\nThis fails.. it expands the wildcards to zero arguments, but it still EXECUTES the command:\r\n```\r\nfizzfaldt@buk ~/fishtest> command /bin/ls -1 -l c*\r\nNo matches for wildcard “c*”.\r\nfish: command /bin/ls -1 -l c*\r\n                            ^\r\ntotal 0\r\n-rw-rw-r-- 1 fizzfaldt fizzfaldt 0 Sep 16 00:38 bar\r\n-rw-rw-r-- 1 fizzfaldt fizzfaldt 0 Sep 16 00:38 foo\r\nfizzfaldt@buk ~/fishtest>\r\n```\r\n\r\n> Note that if no matches are found for a specific wildcard, it will expand into zero arguments, i.e. to nothing.\r\n\r\nThis one works: If I have multiple wildcards, but at least one of them matches something, I get a warning, the non-matching ones become nothing,  the matching one is expanded, and the command is executed:\r\n```\r\nfizzfaldt@buk ~/fishtest> command /bin/ls -1 -l b* c* d*\r\nNo matches for wildcard “c*”.\r\nfish: command /bin/ls -1 -l b* c* d*\r\n                               ^\r\nNo matches for wildcard “d*”.\r\nfish: command /bin/ls -1 -l b* c* d*\r\n                                  ^\r\n-rw-rw-r-- 1 fizzfaldt fizzfaldt 0 Sep 16 00:38 bar\r\nfizzfaldt@buk ~/fishtest> command /bin/ls -1 -l c* b* d*\r\nNo matches for wildcard “c*”.\r\nfish: command /bin/ls -1 -l c* b* d*\r\n                            ^\r\nNo matches for wildcard “d*”.\r\nfish: command /bin/ls -1 -l c* b* d*\r\n                                  ^\r\n-rw-rw-r-- 1 fizzfaldt fizzfaldt 0 Sep 16 00:38 bar\r\n```"},"comment":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/comments/181709883","html_url":"https://github.com/fish-shell/fish-shell/issues/2394#issuecomment-181709883","issue_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2394","id":181709883,"user":{"login":"krader1961","id":7545917,"avatar_url":"https://avatars.githubusercontent.com/u/7545917?v=3","gravatar_id":"","url":"https://api.github.com/users/krader1961","html_url":"https://github.com/krader1961","followers_url":"https://api.github.com/users/krader1961/followers","following_url":"https://api.github.com/users/krader1961/following{/other_user}","gists_url":"https://api.github.com/users/krader1961/gists{/gist_id}","starred_url":"https://api.github.com/users/krader1961/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krader1961/subscriptions","organizations_url":"https://api.github.com/users/krader1961/orgs","repos_url":"https://api.github.com/users/krader1961/repos","events_url":"https://api.github.com/users/krader1961/events{/privacy}","received_events_url":"https://api.github.com/users/krader1961/received_events","type":"User","site_admin":false},"created_at":"2016-02-09T04:49:34Z","updated_at":"2016-02-09T04:49:34Z","body":"I too have been mildly annoyed that typing something like `ls *foobar*` (when no file names contain *foobar*) causes the the command to be run with no arguments. I'm inclined to agree with @faho when he says\r\n\r\n> I believe we all agree that passing the bare \"*\" character is the worst possible solution\r\n\r\nwith respect to the **for**, **set**, or **count** commands.\r\n\r\nWhat is less clear is what should happen with respect to other commands (especially external commands). Other shells I've used, such as *ksh* and *zsh*, either refuse to run the command or pass it the unexpanded glob. In my opinion either of those is preferable to the current fish behavior.\r\n\r\nThe proposed change by @anordal seems to allow someone who cares about distinguishing between a matching glob and a non matching glob to use the **set** command with a subsequent **if** command. This, however, breaks backward compatibility and therefore requires a lot of discussion.\r\n\r\nP.S., Pull request #2719 is a good example of a change where the \"philosophical\" discussions should occur in an issue like this rather than in the pull request. If a pull request is causing feedback about the appropriateness (as opposed to the correctness) of the change then the discussion should be moved to an open issue and the pull request rejected."}}