Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 543100
Collapse All | Expand All

(-)a/bash_completion (-1 / +11 lines)
Lines 536-548 Link Here
536
# @param $2  Name of variable to return result to
536
# @param $2  Name of variable to return result to
537
_quote_readline_by_ref()
537
_quote_readline_by_ref()
538
{
538
{
539
    if [[ $1 == \'* ]]; then
539
    if [ -z "$1" ]; then
540
        # avoid quoting if empty
541
        printf -v $2 %s "$1"
542
    elif [[ $1 == \'* ]]; then
540
        # Leave out first character
543
        # Leave out first character
541
        printf -v $2 %s "${1:1}"
544
        printf -v $2 %s "${1:1}"
545
    elif [[ $1 == ~* ]]; then
546
        # avoid escaping first ~
547
        printf -v $2 ~%q "${1:1}"
542
    else
548
    else
543
        printf -v $2 %q "$1"
549
        printf -v $2 %q "$1"
544
    fi
550
    fi
545
551
552
    # Replace double escaping ( \\ ) by single ( \ )
553
    # This happens always when argument is already escaped at cmdline,
554
    # and passed to this function as e.g.: file\ with\ spaces
555
    [[ ${!2} == *\\* ]] && printf -v $2 %s "${1//\\\\/\\}"
546
    # If result becomes quoted like this: $'string', re-evaluate in order to
556
    # If result becomes quoted like this: $'string', re-evaluate in order to
547
    # drop the additional quoting.  See also: http://www.mail-archive.com/
557
    # drop the additional quoting.  See also: http://www.mail-archive.com/
548
    # bash-completion-devel@lists.alioth.debian.org/msg01942.html
558
    # bash-completion-devel@lists.alioth.debian.org/msg01942.html

Return to bug 543100