-
Notifications
You must be signed in to change notification settings - Fork 932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lxc storage volume copy
completion issue
#14264
Comments
@MusicDin I hope that covers the bug you found about the bogus |
Yes, thanks |
I believe code introduced some different oddities:
In the above, it's listing image volumes (fingerprint) along with instances and image aliases.
I think the Lastly, the bogus/extraneous space after completing the pool name still affects my local machine. |
Is the output of
I'm not observing the extraneous space locally. It's possible that you may have old shell completion artifacts on your machine. Can you please try |
That seems to be it as sourcing a freshly generated completion file works. However I couldn't trace where it'd be coming from:
|
I don't see any logic in my change that would cause a regression for the I'm glad to hear regenerating the completion script worked! Older versions of lxd might have retained completion specifications even though the script in |
It seems only ATM it offers much more:
The storage volume list is
So I tried copying one of every type and only
Odd as I don't see any in a fresh shell:
|
Gotcha, thanks for clarifying!
You'll have to run |
In a fresh terminal with the bogus completions coming from I don't know where:
Could it be that those bogus completions come from an older snap revision? |
I just tested a fresh install of the LXD snap on a fresh VM and I'm observing the extraneous space after tab completing https://github.com/canonical/lxd-pkg-snap/blob/latest-edge/snapcraft.yaml#L1424 |
Added similar completion logic to |
It needs to work with the bash version in core22 (stable and candidate) and core24 (edge). |
Reopening to track the extraneous space issue. |
I believe I've found the problem causing the extraneous space to be added after running snapd intercepts all shell completion requests. Given that the default behaviour of bash completions is to add a space, even though we've added a I'm trying to see if I can get a workaround working - more on this soon :) |
There isn't anything wrong with the completion script we're generating in the snap: root@v1:~# cp /snap/lxd/current/etc/bash_completion.d/snap.lxd.lxc /tmp/comp
root@v1:~# . /tmp/comp
root@v1:~# lxc storage volume copy default/vol1 # no extraneous space |
The logic in our completions script is quite verbose and should handle the no space directive. For versions of bash that don't support I've opened a PR to unhide the |
Here is additional information that I think is relevant to the issue:
So could it be that the complete just thinks it's done with the completion and adds a space in preparation of receiving the next args? |
It looks like the completion receives the right directive. See below from within a bash-5.2# /snap/lxd/current/commands/lxc __complete storage volume copy defa
default/
:2
Completion ended with directive: ShellCompDirectiveNoSpace I've tried editing the completion script to always send a |
Upon further examination of @simondeziel @MusicDin what are your thoughts on changing the CLI for cases like this from
to
Although we would probably need to make similar changes to |
That would be an undesirable CLI break for our users because it would break integrations. |
Gotcha - I've also reached out to the Snap team for guidance on this issue. I'll keep you all posted. |
The snap(d) folks are usually quite approachable if you want some guidance/help (see here :) Update: sorry, I had not read your other comment, glad that you asked them already! Have you tried bind mounting a |
I just gave it a try and was unsuccessful. |
After further debugging, I tried modifying the below check in our completion script to always be if (((directive & shellCompDirectiveNoSpace) != 0)); then
if [[ $(type -t compopt) == builtin ]]; then
__lxc_debug "Activating no space"
compopt -o nospace
else
__lxc_debug "No space directive not supported in this version of bash"
fi
fi After the change, the completions from |
Resolved with canonical/lxd-pkg-snap#630. |
Here's the "completion flow":
@kadinsayani, there is a lot to unpack in the above so please let me if anything is unclear!
The text was updated successfully, but these errors were encountered: