Re: Bash git repository on savannah

2012-01-09 Thread Chet Ramey
On 12/7/11 1:52 PM, Chet Ramey wrote:

 There is now a `devel' branch on the git tree, starting with bash-2.05b
 and bash-3.0-alpha.  There are regular (mostly weekly) snapshot updates,
 each a separate commit to that branch.

The git `devel' branch on savannah now has weekly snapshots up to the
end of 2011.  This is pretty close to an up-to-date look at the current
state of the bash development tree.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: equivalent of Linux readlink -f in pure bash?

2012-01-09 Thread Clark J. Wang
On Wed, Aug 10, 2011 at 18:47, Stephane CHAZELAS stephane_chaze...@yahoo.fr
 wrote:

 2011-08-10, 12:00(+02), Bernd Eggink:
 [...]
  function f
  {
   local OPTIND=1
 
   echo \$1=$1
  }
 
  while getopts abcdefg opt
  do
   echo opt=$opt
   f $opt
  done
  
 
  Calling the sript like this works fine:
script -a -b -c
 
  But calling it like this leads to an endless loop:
script -abc
 [...]
  However, this also loops endlessly. The reason is most likely that bash
  maintains an additional internal variable holding the index of the
  current character, relative to the current word. While this variable is
  not directly accessible by the user, it is set to 0 whenever OPTIND is
  assigned a value.
 [...]

 That would be a bug in bash in my opinion. If OPTIND is marked
 local to the function, it shouldn't affect the behavior of
 parent contexts.

 Note that that bug is also in ksh93, pdksh, mksh and posh
 (though slightly different in that one), but not in ash nor zsh.


Seems like ksh93 (tested with version 93u 2011-02-08) implicitly declares
OPTIND and OPTARG in functions defined in the `function NAME {}' syntax and
everything works fine. But if OPTIND or OPTARG are explicitly declared as
local it may not work as expected.

Wish Chet would consider fixing this problem in future bash releases. :)


 Note that if you set OPTIND local, you probably want to do the
 same for OPTARG (and maybe OPTERR).

 --
 Stephane