{"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":31,"closed_issues":232,"state":"open","created_at":"2015-04-14T07:44:05Z","updated_at":"2016-02-09T21:17:42Z","due_on":null,"closed_at":null},"comments":22,"created_at":"2015-09-16T07:44:20Z","updated_at":"2016-02-10T03:23:20Z","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/182180043","html_url":"https://github.com/fish-shell/fish-shell/issues/2394#issuecomment-182180043","issue_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2394","id":182180043,"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-10T03:23:20Z","updated_at":"2016-02-10T03:23:20Z","body":"@faho wrote:\r\n\r\n> The issue with failglob is that it can't be done 100% - you need at least the ability to check for a failing glob. Whether that can be done inline or needs to be done via doing a set first or maybe even an additional function is an implementation detail, ...\r\n\r\nExactly. Anyone who actually cares whether a glob matches anything should be doing so explicitly via **set** and **test** commands (or some equivalent construct). The question is what should fish do when someone isn't careful and does the equivalent of `random_command *wtf*` where the glob doesn't match any files? The principle of least surprise says to pass the literal glob to the command and let it deal with it because that is what has happened for three decades in most shells."}}