cd -L not behaving as documented with symlinks and ..

2018-07-30 Thread Hugo Gabriel Eyherabide
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale$
uname output: Linux hugo-agile 4.13.0-43-generic #48~16.04.1-Ubuntu SMP Thu
May 17 12:56:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.4
Patch Level: 0
Release Status: release

Description:
According to the documentation, cd -L should resolve symlinks after
evaluating .., and that is indeed the case, unless the canonicalization
fails, in which case it uses the original path, seemingly behaving as cd -P.

More specifically, suppose that in the current working directory /tmp there
only exists a directory a/b and a symlink c->a/b. Then, cd -L c/../; pwd
produces /tmp as expected. However, cd -L c/../b; pwd results in /tmp/a/b,
as opposed to an error (because the directory /tmp/b does not exists).

I believe that pathcanon is correct, and that the problem is in
change_to_directory, when choosing between the canon and non-canon form.

Repeat-By:
See above.
Fix:


Re: segfault w/ localvar_inherit and associative array insert

2018-07-30 Thread Chet Ramey
On 7/25/18 5:37 PM, Grisha Levit wrote:
> shopt -s localvar_inherit
> declare -A var
> f() { declare var+=([0]=X); }; f

This will generate an error about attempting to inherit a value from an
incompatible type.

Chet

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



Feature request: parameter expansion, replace last occurrence

2018-07-30 Thread Alan Beccati

Hi,
While programming a script I found it useful to have parameter expansion 
replace the last occurrence of a given substring instead of the first 
but fund no way to do it. I hope this is the correct place for feature 
requests since I found no searchable location for them to check if it 
was already there.


The idea would be to have a third option to the already existing two:

|${PARAMETER/PATTERN} # replaces first occurrence|

|${PARAMETER//PATTERN} # replaces all occurrences|

I was thinking about |${PARAMETER/%PATTERN} but that is already taken by 
anchored replacement.


With best regards,
Alan
|

--
Dr. Alan Beccati
Jacobs University Bremen gGmbH
Department of Life Sciences and Chemistry
Guest scientist at Max Planck Institute for Marine Microbiology
Microbial Genomics and Bioinformatics Research Group
Celsiusstrasse 1
28359 Bremen
Germany
Phone: +49 (0) 421 2028 909



Re: delcare -a on a nameref in a function modifies nameref instead of target

2018-07-30 Thread Chet Ramey
On 7/29/18 4:04 PM, Grisha Levit wrote:
> I think there's a related regression in the latest devel commit. Creating a
> local variable with the same name as a higher-scoped nameref pointing to an
> unset variable creates a local variable with the name of the target of the
> nameref.

I think forcing the local variable creation to only follow namerefs at
the same variable scope is the right thing to do here.

Chet

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



Re: cd -L not behaving as documented with symlinks and ..

2018-07-30 Thread Chet Ramey
On 7/30/18 7:48 AM, Hugo Gabriel Eyherabide wrote:

> Bash Version: 4.4
> Patch Level: 0
> Release Status: release
> 
> Description:
> According to the documentation, cd -L should resolve symlinks after
> evaluating .., and that is indeed the case, unless the canonicalization
> fails, in which case it uses the original path, seemingly behaving as cd -P.
> 
> More specifically, suppose that in the current working directory /tmp there
> only exists a directory a/b and a symlink c->a/b. Then, cd -L c/../; pwd
> produces /tmp as expected. However, cd -L c/../b; pwd results in /tmp/a/b,
> as opposed to an error (because the directory /tmp/b does not exists).

Yes. Bash has used the directory name passed as an argument as a fallback
if canonicalization fails for a very long time (at least 25 years). POSIX
says this should fail, though, so when running in posix mode, bash returns
failure if the canonicalization fails.

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