{"action":"created","issue":{"url":"https://api.github.com/repos/ros/ros/issues/92","labels_url":"https://api.github.com/repos/ros/ros/issues/92/labels{/name}","comments_url":"https://api.github.com/repos/ros/ros/issues/92/comments","events_url":"https://api.github.com/repos/ros/ros/issues/92/events","html_url":"https://github.com/ros/ros/pull/92","id":109958824,"number":92,"title":"robash: Fix zsh rosservice completion.","user":{"login":"de-vri-es","id":786213,"avatar_url":"https://avatars.githubusercontent.com/u/786213?v=3","gravatar_id":"","url":"https://api.github.com/users/de-vri-es","html_url":"https://github.com/de-vri-es","followers_url":"https://api.github.com/users/de-vri-es/followers","following_url":"https://api.github.com/users/de-vri-es/following{/other_user}","gists_url":"https://api.github.com/users/de-vri-es/gists{/gist_id}","starred_url":"https://api.github.com/users/de-vri-es/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/de-vri-es/subscriptions","organizations_url":"https://api.github.com/users/de-vri-es/orgs","repos_url":"https://api.github.com/users/de-vri-es/repos","events_url":"https://api.github.com/users/de-vri-es/events{/privacy}","received_events_url":"https://api.github.com/users/de-vri-es/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-06T08:26:49Z","updated_at":"2015-10-06T16:39:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ros/ros/pulls/92","html_url":"https://github.com/ros/ros/pull/92","diff_url":"https://github.com/ros/ros/pull/92.diff","patch_url":"https://github.com/ros/ros/pull/92.patch"},"body":"I had to change this for rosservice completion to work correctly. `${words[-1]}` is the message value (possibly empty string) at this point and not the service name. I changed it to `${words[3]}`. `${words[-2]}` should also work, but since the subcommand is already hardcoded as `${words[2]}` and there are no optional options I saw no harm in hardcoding index 3 as well.\r\n\r\nAlso I am very curious why the words array is being accessed sometimes as `${=${(s: :)words[x]}}`. It seems like a very elaborate NOP to me. Why do that over `${words[x]}`?\r\n\r\nAlternatively `${=${(s: :)words}[x]}` is not a NOP (though the second split might be) but seems plain wrong to me. We should not be doing word splitting at all, the shell has already done that while taking into account quotes and escape characters and what not. Flattening the array into a string and then splitting on spaces is simply wrong, not to mention more complex and hard to read.\r\n"},"comment":{"url":"https://api.github.com/repos/ros/ros/issues/comments/145922237","html_url":"https://github.com/ros/ros/pull/92#issuecomment-145922237","issue_url":"https://api.github.com/repos/ros/ros/issues/92","id":145922237,"user":{"login":"de-vri-es","id":786213,"avatar_url":"https://avatars.githubusercontent.com/u/786213?v=3","gravatar_id":"","url":"https://api.github.com/users/de-vri-es","html_url":"https://github.com/de-vri-es","followers_url":"https://api.github.com/users/de-vri-es/followers","following_url":"https://api.github.com/users/de-vri-es/following{/other_user}","gists_url":"https://api.github.com/users/de-vri-es/gists{/gist_id}","starred_url":"https://api.github.com/users/de-vri-es/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/de-vri-es/subscriptions","organizations_url":"https://api.github.com/users/de-vri-es/orgs","repos_url":"https://api.github.com/users/de-vri-es/repos","events_url":"https://api.github.com/users/de-vri-es/events{/privacy}","received_events_url":"https://api.github.com/users/de-vri-es/received_events","type":"User","site_admin":false},"created_at":"2015-10-06T16:39:16Z","updated_at":"2015-10-06T16:39:16Z","body":"@wjwwood: I see. I can't really think of a reason though. What will happen is that arguments containing spaces on the command line (escaped with a backslash or quotes) will be turned into separate array elements. In the original `$words` array, the argument will be just one array element, even if it contains spaces.\r\n\r\nHowever, the behaviour of the original $word array without splitting seems correct to me. After all, that array truly represents the separate command line arguments.\r\n\r\nI can test locally with just `${word[i]}` and see if anything breaks. I doubt I will trigger every code path during my normal usage though."}}