{"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":23,"created_at":"2015-09-16T07:44:20Z","updated_at":"2016-02-10T11:07:11Z","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/182318213","html_url":"https://github.com/fish-shell/fish-shell/issues/2394#issuecomment-182318213","issue_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2394","id":182318213,"user":{"login":"bgeron","id":950328,"avatar_url":"https://avatars.githubusercontent.com/u/950328?v=3","gravatar_id":"","url":"https://api.github.com/users/bgeron","html_url":"https://github.com/bgeron","followers_url":"https://api.github.com/users/bgeron/followers","following_url":"https://api.github.com/users/bgeron/following{/other_user}","gists_url":"https://api.github.com/users/bgeron/gists{/gist_id}","starred_url":"https://api.github.com/users/bgeron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgeron/subscriptions","organizations_url":"https://api.github.com/users/bgeron/orgs","repos_url":"https://api.github.com/users/bgeron/repos","events_url":"https://api.github.com/users/bgeron/events{/privacy}","received_events_url":"https://api.github.com/users/bgeron/received_events","type":"User","site_admin":false},"created_at":"2016-02-10T11:07:11Z","updated_at":"2016-02-10T11:07:11Z","body":"There's some value in sticking with history, but I think both passglob\nand nullglob is *not* what users want by default. And I think people do\ncare by default. I don't think fish needs extremely good reasons to\ndeviate from history, just good reasons, but that's been discussed\nbefore in the script case.\n\nPersonally, when I have a failing glob that's passed to a command, I\noften put echo before it so I can see what was the expanded command\nline. It seems to make sense that fish helps me with this when nothing\nmatches. I don't think it's weird to have to escape *, because loads of\nspecial characters have meaning and need to be escaped.\n\nTo be honest failglob still surprises me regularly, but it's a very\nmild surprise.\n\nCheers, Bram\n\n\n\nOn Wed, 10 Feb 2016, at 03:23 AM, Kurtis Rader wrote:\n> @faho[1] wrote:\n\n\n>> The issue with failglob is that it can't be done 100% - you need at\n>> least the ability to check for a failing glob. Whether that can be\n>> done inline or needs to be done via doing a set first or maybe even\n>> an additional function is an implementation detail, ...\n\n\n> Exactly. Anyone who actually cares whether a glob matches anything\n> should be doing so explicitly via *set* and *test* commands (or some\n> equivalent construct). The question is what should fish do when\n> someone isn't careful and does the equivalent of random_command\n> *wtf* where the glob doesn't match any files? The principle of least\n> surprise says to pass the literal glob to the command and let it\n> deal with it because that is what has happened for three decades in\n> most shells.\n\n\n>\n\n\n> — Reply to this email directly or view it on GitHub[2].\n>\n\n\n>\n\n\n\nLinks:\n\n  1. https://github.com/faho\n  2. https://github.com/fish-shell/fish-shell/issues/2394#issuecomment-182180043\n"}}