Re: Builtins should canonicalize path arguments

2014-01-10 Thread Ondrej Oprala

On 01/09/2014 11:06 PM, Pádraig Brady wrote:

On 01/09/2014 07:19 PM, Chet Ramey wrote:

On 1/9/14 12:42 PM, Ondrej Oprala wrote:

Hi, I investigated this bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=987975
and found out that some of bash's builtins (source at the very least) do
not canonicalize
pathnames given as arguments (builtin "open" is instead fed with the path -
failing in the BZ case).
The builtin "cd" seems to handle relative paths correctly. I think it would
be reasonable to take part of
cd's canonicalization code and use it in other builtins as well. I'd gladly
take care of the patch.
Would upstream consider this a good approach?

I have reservations.  If the user in question wants consistent behavior,
I suggest he use `set -o physical' for a while and see if it does what
he wants.  The solution might be that simple.

See also the coreutils realpath command which might be useful in the general 
case:
http://www.gnu.org/software/coreutils/manual/html_node/realpath-invocation.html

thanks,
Pádraig.

Thank you all for the clarification. I wasn't aware of bash's 
physical/logical approach

towards symlinks.
Have a nice day,
Ondrej



Some Special Array Variables Only Kind Of Initialized

2014-01-10 Thread John R. Graham
Some of the automagically created special array variables (GROUPS and DIRSTACK 
for soer; perhaps others) appear to not be fully initialized. Their values 
don't appear correctly in some corner cases until they've been referenced with 
parameter expansion (I think that's the triggering criteria, anyway). The 
following shell dialog illustrates:
~ $ # Start a new shell.
~ $ bash
~ $ bash --version | head -n1
GNU bash, version 4.2.45(1)-release (i686-pc-linux-gnu)
~ $ # Look at some array variables with 'set'.
~ $ set | grep 'GROUPS\|DIRSTACK'
DIRSTACK=()
GROUPS=()
~ $ # Hmm. Empty? Really?
~ $ echo ${GROUPS[@]}
1000 11 14 18 19 20 27 35 80 85 100 250 995 996 10 1003 1013
~ $ echo ${DIRSTACK[@]}
~
~ $ # Okay, not empty.
~ $ # Look at 'em again with set.
~ $ set | grep 'GROUPS\|DIRSTACK'
DIRSTACK=([0]="~")
GROUPS=([0]="1000" [1]="11" [2]="14" [3]="18" [4]="19" [5]="20" [6]="27" 
[7]="35" [8]="80" [9]="85" [10]="100" [11]="250" [12]="995" [13]="996" 
[14]="10" [15]="1003" [16]="1013")
~ $ # Hmm again. Now shown correctly.
~ $ exit
exit

So far the Bash source code is a somewhat abstruse to me so I thought I'd ask 
for a little help.

Thanks in advance.

- John