mc
mc copied to clipboard
Autocompletion works incorrectly in bash when key contains colon
Expected behavior
Pressing tab should complete the current word by appending rest of the key
Actual behavior
Pressing tab completes the current word by appending full key string
Steps to reproduce the behavior
Enable and test autocompletion
$ mc --autocompletion
mc: Your shell is set to 'bash', by env var 'SHELL'. mc: enabled autocompletion in your 'bash' rc file. Please restart your shell.
$ mc <TAB>
admin du legalhold od retention tag
alias encrypt license ping rm tree
anonymous event ls pipe share undo
cat find mb rb sql update
cp head mirror ready stat version
diff ilm mv replicate support watch
Create the bucket and upload test objects
$ mc mb play/reproducer
Bucket created successfully `play/reproducer`.
$echo "Sample content" > tmp.txt
$ mc cp tmp.txt play/reproducer/co:lon:ed:key/
...n/tmp.txt: 15 B / 15 B ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 26 B/s 0s
$ mc cp tmp.txt play/reproducer/co:lDif:er
...n/tmp.txt: 15 B / 15 B ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 20 B/s 0s
$ mc ls play/reproducer/
[2022-08-24 11:47:18 +03] 15B STANDARD co:lDif:er
[2022-08-24 11:47:21 +03] 0B co:lon:ed:key/
$ mc ls play/reproducer/<TAB>
> mc ls play/reproducer/co:l
$ mc ls play/reproducer/co:l <TAB>
> mc ls play/reproducer/co:play/reproducer/co:l
mc --version
$ mc --version
mc version RELEASE.2022-08-23T05-45-20Z (commit-id=07fffc3bc88f70a73c3714d9af23122f611b76cf) Runtime: go1.18.5 darwin/amd64 Copyright (c) 2015-2022 MinIO, Inc. License GNU AGPLv3 https://www.gnu.org/licenses/agpl-3.0.html
System information
I think it is irrelavant but tested in macOS Monterey Version: 12.4 (21F79).
$ echo $SHELL
/bin/bash
$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin21.1.0) Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
$ echo $COMP_WORDBREAKS
"'><=;|&(:
Disclaimer and extra commentary
I am currently trying to implement autocompletion for another application and have the same problem. So far I found two fixes (that seems to work):
- Removing : from the global COMP_WORDBREAKS
- using bash-completion package to handle colons without changing COMP_WORDBREAKS. But this time the user need to have her bash source the corresponding file by herself.
@taran-p Can you PTAL?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.