[Bug 622403] Re: bash-completion: readline expand-tilde not acknowledged

Launchpad Bug Tracker 622403 at bugs.launchpad.net
Mon Apr 29 07:05:02 UTC 2019


*** This bug is a duplicate of bug 324505 ***
    https://bugs.launchpad.net/bugs/324505

Status changed to 'Confirmed' because the bug affects multiple users.

** Changed in: bash-completion (Ubuntu)
       Status: New => Confirmed

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to bash-completion in Ubuntu.
https://bugs.launchpad.net/bugs/622403

Title:
  bash-completion: readline expand-tilde not acknowledged

Status in bash-completion package in Ubuntu:
  Confirmed

Bug description:
  Binary package hint: bash-completion

  _expand() in /etc/bash_completion, a part of bash-completion, does not
  acknowledge the readline variable expand-tilde as of version
  1.1-3ubuntu2.

  Typing 'ls ~/<tab>' currently results in the command being expanded to
  'ls /home/user/', even with readline's expand-tilde set to off.

  Current _expand():
  _expand()
  {
      # FIXME: Why was this here?
      #[ "$cur" != "${cur%\\}" ] && cur="$cur\\"

      # Expand ~username type directory specifications.  We want to expand
      # ~foo/... to /home/foo/... to avoid problems when $cur starting with
      # a tilde is fed to commands and ending up quoted instead of expanded.

      if [[ "$cur" == \~*/* ]]; then
          eval cur=$cur
      elif [[ "$cur" == \~* ]]; then
          cur=${cur#\~}
          COMPREPLY=( $( compgen -P '~' -u "$cur" ) )
          [ ${#COMPREPLY[@]} -eq 1 ] && eval COMPREPLY[0]=${COMPREPLY[0]}
          return ${#COMPREPLY[@]}
      fi
  }

  The problem lies in the area "eval cur=$cur" as it should only do this
  expansion if readline's expand-tilde is on.

  The following fixes it:
  _expand()
  {
      # FIXME: Why was this here?
      #[ "$cur" != "${cur%\\}" ] && cur="$cur\\"

      # Expand ~username type directory specifications.  We want to expand
      # ~foo/... to /home/foo/... to avoid problems when $cur starting with
      # a tilde is fed to commands and ending up quoted instead of expanded.

      if [[ "$cur" == \~*/* ]]; then
          if [ $(bind -v|grep 'set expand-tilde on'> /dev/null) ]; then
              eval cur=$cur
          else
              return 0;
          fi
      elif [[ "$cur" == \~* ]]; then
          cur=${cur#\~}
          COMPREPLY=( $( compgen -P '~' -u "$cur" ) )
          [ ${#COMPREPLY[@]} -eq 1 ] && eval COMPREPLY[0]=${COMPREPLY[0]}
          return ${#COMPREPLY[@]}
      fi
  }

  This function does perform the intended fix however there may be a
  more effective and efficient manner of resolving this.  This still
  needs to be verified and tested further (for example, in the context
  of a script versus the command line).

  If Ubuntu chooses to set the system-wide default of readline's expand-
  tilde to on, that would be acceptable so long as a user may then
  reconfigure it for a given system or user.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/622403/+subscriptions



More information about the foundations-bugs mailing list