Bug 801889 - bad behaviour of cdargs completion with UTF-8 paths
Summary: bad behaviour of cdargs completion with UTF-8 paths
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 16
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Milos Jakubicek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-03-09 18:42 UTC by Alexey Radkov
Modified: 2012-03-12 09:34 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2012-03-12 09:34:22 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Alexey Radkov 2012-03-09 18:42:38 UTC
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 08:04:46 UTC
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 09:34:22 UTC
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.