Bug 54717 - ucr command line completion not working in screen and sudo shells
ucr command line completion not working in screen and sudo shells
Status: NEW
Product: UCS
Classification: Unclassified
Component: General
UCS 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: Nikola Radovanovic
UCS maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2022-05-05 17:06 CEST by Arvid Requate
Modified: 2022-07-12 11:39 CEST (History)
3 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
Proposed patch (1.20 KB, patch)
2022-07-04 11:21 CEST, Nikola Radovanovic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arvid Requate univentionstaff 2022-05-05 17:06:47 CEST
Noticed during support cases, Phoenix deployments and personal development machines:


In UCS 5.0 the bash command line completion does not work in screen and sudo sessions that are not login sessions.

After running `. /etc/profile` the commands in /etc/profile.d/bash_completion.sh are run and bash completion works.

If `echo $BASH_COMPLETION_VERSINFO` doesn't produce output, then that's not been loaded.

It works when you get a login shell as root directly.
Comment 1 Arvid Requate univentionstaff 2022-06-28 13:55:11 CEST
Workaround:

. /etc/profile.d/bash_completion.sh
Comment 2 Nikola Radovanovic univentionstaff 2022-07-04 11:21:50 CEST
Created attachment 10962 [details]
Proposed patch

Can we try with this one?

I manually edited /etc/bash.bashrc on one of my VMs and rebooted it.
Comment 3 Philipp Hahn univentionstaff 2022-07-06 15:28:37 CEST
A "interactive *non*-login shell" starts sourcing `bashrc` instead of `profile`.
In Debian the later `profile` always sources the former `bashrc` by default.

While /etc/bash.bashrc does *not* source `bash_completion.sh`, this is done explicitly by /etc/skel/.bashrc which normal users get by default.

Completion is neither sourced by /root/.profile nor by /root/.bashrc
For a "root" *login* shell it still is sourced via /etc/profile
These files are all installed by package "base-files" and shipped in /usr/hsare/base-files/{dot.{profile,bashrc},profile}

But `screen` or `sudo` do *not* get completion sourced:
Both do *not* use a "login-shell" by default; you have to explicitly request that using `sudo -i` or `screen -s -bash`.
As such they use `/root/.bashrc` only, which does not source completion.

See <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=275623#54>

<https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html>

# interactive login
`bash --login` | `-bash`
+- `--noprofile`
   +- /etc/profile
   |  . /etc/bash.bashrc
   |  . /etc/profile.d/*.sh
   |      . /etc/profile.d/bash_completion.sh
   +--+- $HOME/.bash_profile
      +- $HOME/.bash_login
      +- $HOME/.profile
         . $HOME/.bashrc
`sh --login` | `-sh`
+- `--noprofile`
   +- /etc/profile
   +- $HOME/.profile

# interactive non-login shell
`bash -i`
+--+- `--norc`
   +- `--rcfile …`
   +- $HOME/.bashrc
   +- /etc/bash.bashrc
`sh -i`
+- $ENV

# non-interactive non-login shell
`bash -c` | `#!/bin/bash`
+- $BASH_ENV
`sh -c` | `#!/bin/sh`
NOTHING


(In reply to Nikola Radovanovic from comment #2)
> Created attachment 10962 [details]
> Proposed patch

No, the "bug" is in /root/.bashrc (AKA /usr/share/base-files/dot.bashrc) not sourcing /etc/profile.d/bash_completion.sh


(In reply to Arvid Requate from comment #0)
> In UCS 5.0 the bash command line completion does not work in screen and sudo
> sessions that are not login sessions.

Use `sudo -i` or `screen -s -bash` for now.
Comment 4 Nikola Radovanovic univentionstaff 2022-07-12 11:39:01 CEST
Thank you!