Bug 801889 - bad behaviour of cdargs completion with UTF-8 paths
bad behaviour of cdargs completion with UTF-8 paths
Status: CLOSED WORKSFORME
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
16
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Milos Jakubicek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-09 13:42 EST by Alexey Radkov
Modified: 2012-03-12 05:34 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-03-12 05:34:22 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Alexey Radkov 2012-03-09 13:42:38 EST
Description of problem:

I use cdargs since Fedora 10 or even maybe earlier. It always worked fine for me, but it got broken in Fedora 16. I use russian locale and my home doc/ video/ etc. directories have russian names: Документы/, Видео/ etc. I use cdargs to say just, for example, 'cv docs/' to cd to Документы/. Since Fedora 16 i get error messages like following when using bash completion with tabs:

cv docs/sed: -e выражение #1, символ 10: неизвестный модификатор к `s'
sed: -e выражение #1, символ 10: неизвестный модификатор к `s'
sed: -e выражение #1, символ 10: неизвестный модификатор к `s'

Same 3 lines in Russian are result of triple key Tab pressing. They say:

sed: -e expression #1, symbol 10: unknown modifier to 's'.

After some investigation i found that problem is in file /etc/profile.d/cdargs.sh in function _cdargs_aliases() in the line where variable $strip is created:

                strip="${dir//?/.}"

then it is used in lines:

                COMPREPLY=( $(
                    compgen -d "$dir`echo "$cur" | sed 's#^[^/]*##'`" \
                        | sed -e "s/^$strip/$bookmark/" -e "s/\([^\/a-zA-Z0-9#%_+\\\\,.-]\)/\\\\\\1/g" ) )


The author's original idea was to change all symbols in $dir by dots ('.'). This really works when all symbols are english, here are examples from my bash:

$ AAA='/a/b/c'
$ echo ${AAA//?/.}
......

But in my bash (bash-4.2.20-1.fc16.x86_64) it does not work with russian symbols:

$ AAA='/a/b/c/путь'
$ echo ${AAA//?/.}
/a/b/c/путь

You can see that bash's string replacement operator just does nothing! So,

PROBABLY THIS IS BASH ISSUE,

i do not know the meanings of '?' here well. Then the error messages of sed are obvious: it just tries to replace something like

s//a/b/c/путь/$bookmark/



Also simple solution:

strip=$(echo $dir | sed 's/././g')

instead original line

strip="${dir//?/.}"

works fine because sed's 'dot' regexp matches russian (UTF-8) characters.



Version-Release number of selected component (if applicable):

cdargs-1.35-7.fc15.x86_64
Comment 1 Alexey Radkov 2012-03-11 04:04:46 EDT
I tested bash string replacement in Fedora 14 (bash-4.1.7-4.fc14.x86_64). It works fine:

$ AAA='/a/b/c/путь'
$ echo ${AAA//?/.}
...........

So looks like this is BASH ISSUE.
Comment 2 Roman Rakus 2012-03-12 05:34:22 EDT
Works for me:
$ AAA='/a/b/c/путь'
$ echo ${AAA//?/.}
...........
$ rpm -q bash
bash-4.2.20-1.fc16.x86_64

Note You need to log in before you can comment on or make changes to this bug.