diff mbox series

[RFC,kvm-unit-tests,v2,08/14] shellcheck: Fix SC2013

Message ID 20240406123833.406488-9-npiggin@gmail.com (mailing list archive)
State New, archived
Headers show
Series add shellcheck support | expand

Commit Message

Nicholas Piggin April 6, 2024, 12:38 p.m. UTC
SC2013 (info): To read lines rather than words, pipe/redirect to a
  'while read' loop.

Not a bug.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 scripts/arch-run.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Jones April 8, 2024, 7:34 a.m. UTC | #1
On Sat, Apr 06, 2024 at 10:38:17PM +1000, Nicholas Piggin wrote:
>   SC2013 (info): To read lines rather than words, pipe/redirect to a
>   'while read' loop.
> 
> Not a bug.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  scripts/arch-run.bash | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> index cd75405c8..45ec8f57d 100644
> --- a/scripts/arch-run.bash
> +++ b/scripts/arch-run.bash
> @@ -487,7 +487,7 @@ env_file ()
>  
>  	[ ! -f "$KVM_UNIT_TESTS_ENV_OLD" ] && return
>  
> -	for line in $(grep -E '^[[:blank:]]*[[:alpha:]_][[:alnum:]_]*=' "$KVM_UNIT_TESTS_ENV_OLD"); do
> +	grep -E '^[[:blank:]]*[[:alpha:]_][[:alnum:]_]*=' "$KVM_UNIT_TESTS_ENV_OLD" | while IFS= read -r line ; do
>  		var=${line%%=*}
>  		if ! grep -q "^$var=" $KVM_UNIT_TESTS_ENV; then
>  			eval export "$line"
> -- 
> 2.43.0
>

I already gave an r-b on this one. Here it is again,

Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Nicholas Piggin April 10, 2024, 4:29 a.m. UTC | #2
On Mon Apr 8, 2024 at 5:34 PM AEST, Andrew Jones wrote:
> On Sat, Apr 06, 2024 at 10:38:17PM +1000, Nicholas Piggin wrote:
> >   SC2013 (info): To read lines rather than words, pipe/redirect to a
> >   'while read' loop.
> > 
> > Not a bug.
> > 
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> >  scripts/arch-run.bash | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> > index cd75405c8..45ec8f57d 100644
> > --- a/scripts/arch-run.bash
> > +++ b/scripts/arch-run.bash
> > @@ -487,7 +487,7 @@ env_file ()
> >  
> >  	[ ! -f "$KVM_UNIT_TESTS_ENV_OLD" ] && return
> >  
> > -	for line in $(grep -E '^[[:blank:]]*[[:alpha:]_][[:alnum:]_]*=' "$KVM_UNIT_TESTS_ENV_OLD"); do
> > +	grep -E '^[[:blank:]]*[[:alpha:]_][[:alnum:]_]*=' "$KVM_UNIT_TESTS_ENV_OLD" | while IFS= read -r line ; do
> >  		var=${line%%=*}
> >  		if ! grep -q "^$var=" $KVM_UNIT_TESTS_ENV; then
> >  			eval export "$line"
> > -- 
> > 2.43.0
> >
>
> I already gave an r-b on this one. Here it is again,
>
> Reviewed-by: Andrew Jones <andrew.jones@linux.dev>

Yeah I realised just after sending. Thank you.

Thanks,
Nick
diff mbox series

Patch

diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index cd75405c8..45ec8f57d 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -487,7 +487,7 @@  env_file ()
 
 	[ ! -f "$KVM_UNIT_TESTS_ENV_OLD" ] && return
 
-	for line in $(grep -E '^[[:blank:]]*[[:alpha:]_][[:alnum:]_]*=' "$KVM_UNIT_TESTS_ENV_OLD"); do
+	grep -E '^[[:blank:]]*[[:alpha:]_][[:alnum:]_]*=' "$KVM_UNIT_TESTS_ENV_OLD" | while IFS= read -r line ; do
 		var=${line%%=*}
 		if ! grep -q "^$var=" $KVM_UNIT_TESTS_ENV; then
 			eval export "$line"