salesforce-cli-bash-completion icon indicating copy to clipboard operation
salesforce-cli-bash-completion copied to clipboard

add support for bash Version 4

Open Falcosc opened this issue 5 years ago • 7 comments

The colon fix was missing at the cur and prev assignment.

Now bash version 4 is supported for devices newer than 2009 ;)

On some distros you may need to install bash-completion package. On Windows you already have bash4 and bash-completion with git bash mingw. On cygwin you may need to install bash-completion to get _get_comp_words_by_ref

Falcosc avatar Jun 25 '19 06:06 Falcosc

This looks like a great update but sadly I don't know enough to know if this will break a lot of people. @Falcosc IIRC, this was the hardest part about getting it to work with bash. Do you have any suggestions on how I can best test this out to ensure I don't break people? Thank you!

wadewegner avatar Jul 06 '19 19:07 wadewegner

Install bash v4 on your mac or use linux with bash v4 or a VM with windows and gitbash or if you would like to test even more, windows 10 with wsl but that should be same as linux.

At the end it can be only go better because current version is already broken and do only work with the 9 years old bash v3.

Falcosc avatar Jul 06 '19 19:07 Falcosc

I just tested changing that one liner and working perfect under Windows 10 gitbash mingw64. Thank you! This tool is great. 👍😎

gdemarcosSFDC avatar Aug 02 '19 08:08 gdemarcosSFDC

I just verified that this change works great on Bash 4 under Cygwin, Mingw, and Ubuntu (both WSL and a dedicated install), but it also breaks Bash 3 which is the default on Mac OS X. The change should be conditional based on the version of Bash with the original behavior used on Bash 3 and the new behavior on Bash 4+.

SCWells72 avatar Aug 07 '19 18:08 SCWells72

You just need to install bash-completion on mac or any other environment which doesn't have this by default. If you don't have bash-completion you get just the message that you are missing functions from bash-completion.

It's bad practice to copy sourcecode from bash-completion into this script like this: https://github.com/wadewegner/salesforce-cli-bash-completion/blob/master/sfdx.bash#L10

Better would be something like this: if __ltrim_colon_completions or _get_comp_words_by_ref is missing: echo "Please install bash-completion"

I will not put any bash-completion source code copy into this pullrequest.

Falcosc avatar Aug 07 '19 18:08 Falcosc

master did not work on RHEL7. This branch works perfect.

baksale avatar Jun 25 '20 17:06 baksale

Tested it on WSL2 and works 👍

juan-cs avatar Jun 26 '20 19:06 juan-cs