FS#50727 - [aws-cli] Shell completion files in wrong dir

Attached to Project: Community Packages
Opened by Guillaume ALAUX (galaux) - Saturday, 10 September 2016, 13:08 GMT
Last edited by Jonathan Steel (jsteel) - Tuesday, 27 September 2016, 18:41 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Jonathan Steel (jsteel)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

After installing `aws-cli` package, one does not have shell completion because some files look misplaced:

- `usr/bin/aws_bash_completer`
- `usr/bin/aws_completer`
- `usr/bin/aws_zsh_completer.sh`

These should not belong to a PATH dir.
For ZSH this should be somewhere around `/usr/share/zsh/` I guess (not a ZSH nor Bash specialist).

Also, package contains this Windows shell script that we could get rid of: `/usr/bin/aws.cmd`!
This task depends upon

Closed by  Jonathan Steel (jsteel)
Tuesday, 27 September 2016, 18:41 GMT
Reason for closing:  Fixed
Comment by Jonathan Steel (jsteel) - Saturday, 10 September 2016, 14:16 GMT
Bash completion works for me: /usr/share/bash-completion/completions/aws

I'll work out where the ZSH one should go (though I believe ZSH can use the bash completion) and tidy up the files from /usr/bin. That was a default from upstream.
Comment by Jonathan Steel (jsteel) - Monday, 12 September 2016, 22:15 GMT
I've removed the windows script and the bash one (as I've already put the bash one in the correct location).

From a quick look I think the ZSH script is to enable bash-compatible completion in ZSH. Users may have sourced this as per AWS docs so I'm inclined to leave this one. I think the aws_completer file should also stay there, as the completion scripts require it to be in your PATH. I could patch but probably best to report this upstream.
Comment by Guillaume ALAUX (galaux) - Tuesday, 13 September 2016, 14:12 GMT
Yes it seems `/usr/bin/aws_completer` should be accessible in PATH because it is used by `/usr/bin/aws_zsh_completer.sh`. So my bad: `/usr/bin/aws_completer` should stay.

By having a look at the comment in `/usr/bin/aws_zsh_completer.sh`, its whole `_bash_complete()` function is useless (is only useful for old ZSH). I guess `aws_zsh_completer.sh` could be removed as it currently serves no use. Anyone willing to use ZSH completion just needs to add the following to its `.zshrc` (as explained in the official doc [0]):

```
autoload -Uz bashcompinit
bashcompinit -i
complete -C aws_completer aws
```

[0] https://github.com/aws/aws-cli#command-completion
Comment by Jonathan Steel (jsteel) - Tuesday, 13 September 2016, 17:41 GMT
That link says "source bin/aws_zsh_completer.sh". So happy to leave it there?
Comment by Guillaume ALAUX (galaux) - Tuesday, 13 September 2016, 18:48 GMT
That link says "source the script" which itself contains a comment stating:

```
# % source /path/to/zsh_complete.sh
#
# Typically that would be called somewhere in your .zshrc.
#
# Note, the overwrite of _bash_complete() is to export COMP_LINE and COMP_POINT
# That is only required for zsh <= edab1d3dbe61da7efe5f1ac0e40444b2ec9b9570
#
# https://github.com/zsh-users/zsh/commit/edab1d3dbe61da7efe5f1ac0e40444b2ec9b9570
#
# zsh relases prior to that version do not export the required env variables!
```

The mentioned commit dates back from Jan 4, 2013. Our ZSH is way past it.

I think what is really interesting here is to understand the intention behind upstream providing `aws_zsh_completer.sh` which IMO is to show what one should have in his/her .zshrc to enable completion. And for our – recent – version of ZSH, this would just be the 3 remaining lines:

```
autoload -Uz bashcompinit
bashcompinit -i
complete -C aws_completer aws
```

Don't take me wrong: I am really discussing a technicality here ;). I just added these 3 lines in my .zshrc – waiting for a "proper ZSH auto completion" as mentioned in the same comment – and everything works like a charm so this file really does not bother me.

Loading...