{"action":"created","issue":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2438","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2438/labels{/name}","comments_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2438/comments","events_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2438/events","html_url":"https://github.com/fish-shell/fish-shell/issues/2438","id":108620781,"number":2438,"title":"Undefined variables cause brace-expansion to fail?","user":{"login":"alphapapa","id":601365,"avatar_url":"https://avatars.githubusercontent.com/u/601365?v=3","gravatar_id":"","url":"https://api.github.com/users/alphapapa","html_url":"https://github.com/alphapapa","followers_url":"https://api.github.com/users/alphapapa/followers","following_url":"https://api.github.com/users/alphapapa/following{/other_user}","gists_url":"https://api.github.com/users/alphapapa/gists{/gist_id}","starred_url":"https://api.github.com/users/alphapapa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphapapa/subscriptions","organizations_url":"https://api.github.com/users/alphapapa/orgs","repos_url":"https://api.github.com/users/alphapapa/repos","events_url":"https://api.github.com/users/alphapapa/events{/privacy}","received_events_url":"https://api.github.com/users/alphapapa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-09-28T09:31:49Z","updated_at":"2015-09-30T11:53:00Z","closed_at":null,"body":"```fish\r\n$ set foo fizz\r\n$ set bar buzz\r\n$ echo {$foo}{$bar}\r\nfizzbuzz\r\n```\r\nHowever:\r\n```fish\r\n$ set bar buzz\r\n$ echo {$foo}{$bar}\r\n$\r\n```\r\nAnd:\r\n```fish\r\n$ set foo \"\"\r\n$ set bar buzz\r\n$ echo {$foo}{$bar}\r\nbuzz\r\n```\r\nShouldn't the second example output `buzz`?"},"comment":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/comments/144373654","html_url":"https://github.com/fish-shell/fish-shell/issues/2438#issuecomment-144373654","issue_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2438","id":144373654,"user":{"login":"faho","id":5185367,"avatar_url":"https://avatars.githubusercontent.com/u/5185367?v=3","gravatar_id":"","url":"https://api.github.com/users/faho","html_url":"https://github.com/faho","followers_url":"https://api.github.com/users/faho/followers","following_url":"https://api.github.com/users/faho/following{/other_user}","gists_url":"https://api.github.com/users/faho/gists{/gist_id}","starred_url":"https://api.github.com/users/faho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faho/subscriptions","organizations_url":"https://api.github.com/users/faho/orgs","repos_url":"https://api.github.com/users/faho/repos","events_url":"https://api.github.com/users/faho/events{/privacy}","received_events_url":"https://api.github.com/users/faho/received_events","type":"User","site_admin":false},"created_at":"2015-09-30T11:53:00Z","updated_at":"2015-09-30T11:53:00Z","body":">Aha, you are cool. ;)\r\n\r\nIf it seems that way now, wait til I put on my robe and wizard hat.\r\n\r\n>$ echo {${letters[@]},${numbers[@]}}\r\n\r\nand\r\n\r\n>{$alpha}{$beta}\r\n\r\nNo - literal brace expansion. In fish:\r\n\r\n```fish\r\n$ set a 1 2 3\r\n$ set b a b c\r\n$ echo $a$b\r\n1a 2a 3a 1b 2b 3b 1c 2c 3c\r\n$ echo {1,2,3}{a,b,c}\r\n1a 2a 3a 1b 2b 3b 1c 2c 3c\r\n```\r\n\r\nIn that way, `{1,2,3}` is the literal version of a variable set to `1 2 3` - because fish expands braces even for single elements, it even works for single-element lists.\r\n\r\n>I didn't do a comprehensive check, but I looked at /usr/share/fish/functions/*ssh.fish and didn't notice any CartPs.\r\n\r\nhttps://github.com/fish-shell/fish-shell/blob/b85a8bbbfed56f603dca5d6da85858f9c973b669/share/completions/ssh.fish#L12-L14 and https://github.com/fish-shell/fish-shell/blob/b85a8bbbfed56f603dca5d6da85858f9c973b669/share/completions/ssh.fish#L17-L19 - it basically generates \"$user@$hostname\" type things - with all known users and all known hostnames.\r\n\r\n>I think that wouldn't work as-is (where is $token defined?)\r\n\r\nSorry, missed that one.\r\n\r\n>But that's exactly my point: You are an expert, a Fish developer, no-less. You are well aware of cart-ps and the syntax for them and when and how to use them.\r\n\r\nI think you give me too much credit :blush: - I'm no superman (cue Scrubs theme song).\r\n\r\nAnyway, I don't think you got my point: For any substitution that's not going to the screen - this is basically anything that's not passed to `echo` or `printf` and then not redirected via command substitution or something - the bash version is just _wrong_. Imagine passing something to `ls`, and then it turns out it's accidentally become a list. Say \"$a\" is \"/usr/ /bin/ /lib/\" and \"$b\" is \"share\", and you wanted to get the contents of \"/usr/share\" but then someone changed \"$a\" to be a list. Now you get a ton of output for the contents of /usr and /bin, and at the top there's an error message about \"/lib/share\". This is similar to the `$PATH/*` example - the interpretation that you want the glob to apply to just the last part of `$PATH` is ridiculous, and not in a fishy way.\r\n\r\n>if it merely concat'ed the lists\r\n\r\nThat's what I've been trying to say: There is _no obvious way_ to \"just concat\" two lists. Or rather, there is what python does with `list1 + list2`, but that's `$a $b` in shell, and behaves different than when the variables only have one element.\r\n\r\n>Here's something I discovered a few minutes ago, a rather nasty example:\r\n\r\n>echo (ls /usr/share/doc)(ls /usr/bin)\r\n\r\nNice - my system does that in two seconds flat (and I'd expect almost half a million results). Make it `echo (ls /usr/share/doc)(ls /usr/bin)(ls /etc)` and then we're talking - I aborted when that fish instance took over two gigs of memory. Anyway, the point is taken. I'm afraid I don't have a good answer.\r\n\r\n>we've already seen that some people are running Fish on supercomputers\r\n\r\nAnd that's just amazingly cool, right?\r\n\r\n\r\n\r\n\r\n\r\n\r\n "}}