Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] bash_completion: improvement, fixes and tests [was: Re: subversion and programmable completion]



Julian Foad <julianfoad@xxxxxxxxxxxxxxx> writes:

> But just to > check, try
>
> ~> echo 's/[(,]/\n/g' | hexdump -C
> 00000000  73 2f 5b 28 2c 5d 2f 5c  6e 2f 67 0a              |s/[(,]/\n/g.|

$ echo 's/[(,]/\n/g' | hexdump -C
00000000  73 2f 5b 28 2c 5d 2f 5c  6e 2f 67 0a              |s/[(,]/\n/g.|
0000000c

> Work-arounds: these all work for me; I'd be interested to know which
> work for you and which don't.

Results below are for sed and tr from the stable Debian distribution.
Looking at the package documentation, the sed info pages and faq both
cover s/// but are worded slightly differently!

> 1. Use "tr" instead of "sed"; unlike sed, its escape sequences are
>    explicitly listed in its man page:
> ~> tr --version | head -1
> tr (textutils) 2.1
> ~> echo 'x(y' | tr '(,' '\n'

$ echo 'x(y' | tr '(,' '\n'
x
y

> 2. insert a literal newline character after the backslash, instead
>    of 'n'; this is explicitly listed in the manual page:
> ~> echo 'x(y' | sed 's/[(,]/\
> /g'

$ echo 'x(y' | sed 's/[(,]/\
/g'
x
y

> 3. Use numeric escape sequences; these are not mentioned in the
>    manual but work for me:
> ~> echo 'x(y' | sed 's/[(,]/\o012/g'

$ echo 'x(y' | sed 's/[(,]/\o012/g'
xo012y

> ~> echo 'x(y' | sed 's/[(,]/\d010/g'

$ echo 'x(y' | sed 's/[(,]/\d010/g'
xd010y

> ~> echo 'x(y' | sed 's/[(,]/\x0A/g'

$ echo 'x(y' | sed 's/[(,]/\x0A/g'
xx0Ay

> Attached is a version of bash_completion_test using "tr", which I
> think is the safest solution.  And to keep the patch together, the
> original bash_completion.diff is also attached and the log message
> is repeated here:

Thanks!  I checked in a slightly modified version in r6557.

-- 
Philip Martin



Messages sorted by: Reverse Date, Date, Thread, Author