[LEDE-DEV] [patch master 13/15] To read lines rather than words, pipe/redirect to a 'while read' loop

Jan-Tarek Butt tarek at ring0.de
Sun Oct 2 03:30:30 PDT 2016


Hi,

On 10/01/16 11:09, Oswald Buddenhagen wrote:
> On Sat, Oct 01, 2016 at 12:44:36AM +0200, Lars Kruse wrote:
>> Am Fri, 30 Sep 2016 22:02:27 +0200 schrieb Jan-Tarek Butt <tarek at ring0.de>:
>>
>>> ---
>>>  scripts/deptest.sh | 8 ++++----
>>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/scripts/deptest.sh b/scripts/deptest.sh
>>> index 8c859ef..0b0e7a9 100755
>>> --- a/scripts/deptest.sh
>>> +++ b/scripts/deptest.sh
>>> @@ -86,9 +86,9 @@ test_package() # $1=pkgname
>>>  	[ -n "$pkg" -a -z "$(echo "$pkg" | grep -e '/')" -a "$pkg" != "." -a "$pkg" != ".." ] || \ die "Package name \"$pkg\" contains illegal characters"
>>>  	local SELECTED=
>>> -	for conf in $(grep CONFIG_PACKAGE tmp/.packagedeps | grep -E "[ /]$pkg\$" | sed -e 's,package-$(\(CONFIG_PACKAGE_.*\)).*,\1,'); do
>>> +	while IFS= read -r conf; do
>>>  		grep "$conf=" .config > /dev/null && SELECTED=1 && break
>>> -	done
>>> +	done < "$(grep CONFIG_PACKAGE tmp/.packagedeps | grep -E "[ /]$pkg\$" | sed -e 's,package-$(\(CONFIG_PACKAGE_.*\)).*,\1,')"
>>
>> Is this really doing what it looks like?
>>   ... < "$(command)"
>> This should try to read from a file named like the output of "command" - and
>> not the lines of command's output.
>>
>> I guess, the following approach should do the right thing:
>>
>>   grep CONFIG_PACKAGE tmp/.packagedeps | grep -E > "[ /]$pkg\$" | sed -e 's,package-$(\(CONFIG_PACKAGE_.*\)).*,\1,') | while IFS= read -r conf; do
>>     ...
>>   done
>>
> this won't work, because it makes the loop body a subshell, and thus the
> assignment of SELECTED will get lost.
> 
> to achieve the goal with minimal effort, adding
> 
>   local IFS=$'\n'
> 
> prior to the loop should be sufficient.

I rejected this patch
because I did a mistake here. The for loops reading each word and my while loops reading lines.

vg
Tarek

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20161002/06b4354c/attachment.sig>


More information about the Lede-dev mailing list