[Bash-completion-devel] some patches from a git repo

Ville Skyttä ville.skytta at iki.fi
Tue May 3 19:25:16 UTC 2011


On 05/03/2011 09:42 PM, Raph wrote:
> On Tue, May 03, 2011 at 09:22:00PM +0300, Ville Skyttä wrote:
>> -D|--database: What's the -E argument to sed?
> Extended regexp (to avoid too much backslashes) but I not sure whether or not
> it's cross-platform.

It isn't.  For example my sed (GNU sed 4.2.1) does not document it in
the man page or --help output, don't know if it works nevertheless.  My
sed does on the other hand document -r/--regexp-extended for that
purpose but that isn't portable either.  POSIX sed has only -n, -e, and
-f; no extended regexps there.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html

http://pubs.opengroup.org/onlinepubs/9699919799/ -> Shell & Utilities ->
Utilities is a useful resource.  That's the 2008 edition, the older 2004
one is at http://pubs.opengroup.org/onlinepubs/009695399/ (for even more
conservative use of various tools).

In my experience awk has fewer portability issues than sed, but then
again a lot of things these tools and grep, cut, tr etc are used for
could be done in pure bash nowadays as well, but that'll often require a
few more lines of code.  For portability and maintainability that's good
however, and I personally intend to start doing more things in bash
where it's not too cumbersome for my taste in the future.

>> --default-character-set: the -I argument to ls is not portable, and I
>> suppose this could be done fairly easily without ls and sed
>> altogether.
> At the time I wrote it I didn't find alternative as the mysql doc stated
> that the mysql client look into this directory to find encodings.

What the dir is isn't my point, my point is portability of how tools to
access the dir are used, specifically the -I option to ls.  Something
like this should be portable:

$( command ls /usr/share/mysql/charsets 2>/dev/null \
   | sed -e '/Index\.xml/d' -ne 's/.xml$//p' )

...or it could be done in pure bash, for example:

files=( /usr/share/mysql/charsets/!(Index).xml )
files=( ${files[@]##*/} ) ; files=( ${files[@]%.xml} )

...but that's a bit ugly.  (Maybe there's a more elegant way to do it in
pure bash, but that's the first one I thought of.)

>>> - 2 versions of the wget completion
>>
>> Why 2 versions?  What are the differences, and which one do you
>> recommend?  I don't think we want more than one completion per
>> command.
> bash 4 and bash 3 compatible versions (-o filenames, ...)

Okay, we now require 4.1+ so the choice is clear, I'll look into this,
but it'll probably take more than a few days until I get to it.  Others
are welcome to beat me to it ;)



More information about the Bash-completion-devel mailing list