symfony-console-completion: Unable to autocomplete with sudo
Hi there,
we from Nextcloud started using the completion and it works quite fine in general.
The only problem is, that it is impossible to run the stuff with e.g. sudo -u www-data.
This is the recommanded easy-default for Nextcloud, to simply have all code and files owned by the www-data user. But I am unable to --generate-hook in this case.
I’m not sure if this is fixable, but would be very cool if so. I tried adding a copy of a generated hook script manually in /etc/bash_completion.d/ but when trying to modify the script to add sudo -u www-data on the calls, it seems to not execute properly anymore.
Any idea/workaround?
Cheers and keep it up
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 35 (15 by maintainers)
I got it working like this:
SHELLvariable is needed to generate the hook script. Alternatively--shell-type bashor--shell-type zshcan be used, in which cases theSHELLvariable is not required.sudo.What indeed would help is:
--sudo-user=USERand/or reading it fromSUDO_USERvariable, to addsudo -u USER --preserve-env=CMDLINE_CONTENTS,CMDLINE_CURSOR_INDEX,CMDLINE_WORDBREAKSto the hook script automatically.phpcommand is required as well in case of Nextcloud, since theoccscript is not executable OOTB. More logic could solve this:[[ -x $completionCommand ]] || completionCommand="php $completionCommand"(respectively doing this in PHP hook factory already.