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

Raph gibboris at gmail.com
Wed May 4 09:42:15 UTC 2011


On Tue, May 03, 2011 at 10:25:16PM +0300, Ville Skyttä wrote:
> 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.
You're right, -E works like -r in my version but I was probably confused
with grep -E.
Is -r cross-platform ? \w is handy.
I'll look in the doc below...

> 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.)
wow, interesting. I should consider this.



More information about the Bash-completion-devel mailing list