bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IFS is ignored for nested functions with stdin redirection


From: Andrey Borzenkov
Subject: Re: IFS is ignored for nested functions with stdin redirection
Date: Sun, 2 Dec 2012 23:03:12 +0400

В Sun, 2 Dec 2012 20:52:00 +0400
Andrey Borzenkov <address@hidden> пишет:

> I hit this problem in DKMS code and could reduce it to the following
> example:
> 
> ======
> #!/bin/bash
> 
> oifs=$IFS
> 
> inner () {
>       echo a/b/c/d
>       exit 0
> }
> 
> outer() {
> for i in 1; do
>       IFS=/ read m v k a < <(IFS=$oifs inner)
> 
> echo $m:$v:$k:$a
> done
> }
> 
> outer
> 
> for j in 1; do
>       IFS=: read a b c d
> done < <(outer)
> 
> echo $a-$b-$c-$d
> =========
> address@hidden:/tmp> ./t
> a:b:c:d
> a/b/c/d---
> address@hidden:/tmp> 
> =========
> 
> 
> Now insert *any* redirection before call to inner in outer function.
> It magically starts to work again:
> 
> =========
> #!/bin/bash
> 
> oifs=$IFS
> 
> inner () {
>       echo a/b/c/d
>       exit 0
> }
> 
> outer() {
> for i in 1; do
>       : > /dev/null
>       IFS=/ read m v k a < <(inner)
> 
> echo $m:$v:$k:$a
> done
> }
> 
> outer
> 
> for j in 1; do
>       IFS=: read a b c d
> done < <(outer)
> 
> echo $a-$b-$c-$d
> ========
> address@hidden:/tmp> ./t
> a:b:c:d
> a-b-c-d
> address@hidden:/tmp> 
> ========
> 
> This is bash on openSUSE 12.2, bash-4.2-51.6.1.x86_64. Anyone can
> reproduce it as well?
> 

The bug is present in current GIT head and is not present in GIT tag
bash-4.0. Unfortunately attempt to bisect it choked in the middle where
bash does not compile. Here is bisect log:

address@hidden:~/src/bash> git bisect log
git bisect start
# bad: [11d0fdf779380d2951b9ff0cc37a6872cb1a7438] Bash-4.2 patch 39
git bisect bad 11d0fdf779380d2951b9ff0cc37a6872cb1a7438
# good: [89a92869e56aba4e4cab2d639c00a86f0545c862] Bash-4.0 patchlevel 38
git bisect good 89a92869e56aba4e4cab2d639c00a86f0545c862
# bad: [b4d40164691e23c7c546daa57c411907a2c2e8cf] Bash-4.2 patch 17
git bisect bad b4d40164691e23c7c546daa57c411907a2c2e8cf
# bad: [eafc91a3506a082956fbdc8f0fb1210d00f1e035] Bash-4.2 patch 6
git bisect bad eafc91a3506a082956fbdc8f0fb1210d00f1e035
# bad: [49ed961bb057ad481b8f22066d55526ecdfb3c09] Bash-4.2 patch 1
git bisect bad 49ed961bb057ad481b8f22066d55526ecdfb3c09
# skip: [30d188c2932d6ef609d894fefeb7e7b03ccff463] Bash-4.1 patchlevel 11
git bisect skip 30d188c2932d6ef609d894fefeb7e7b03ccff463
# bad: [495aee441b75276e38c75694ccb455bb6463fdb9] Bash-4.2 distribution sources 
and documentation
git bisect bad 495aee441b75276e38c75694ccb455bb6463fdb9
address@hidden:~/src/bash> 

Current commit does not compile

0001803f0b9523c94fa2ede48eaecb047fef4524

I also could not compile commit
30d188c2932d6ef609d894fefeb7e7b03ccff463 and had to skip it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]