Skip to contentSkip to conversation

scripts/arch-run: print stderr immediately

PATCH Superseded Radim Krčmář 3 participants 5 messages Nov 2, 2016 – Nov 3, 2016 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/arch-run: print stderr immediately

Not doing so hid stderr output when the test was stuck and subsequently killed with ^C.

---
 scripts/arch-run.bash | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/arch-run.bash +1 -2
index 8e75c6ed6e17..326f59484e2b 100644
@@ -30,12 +30,11 @@ run_qemu ()
 
 	# stdout to {stdout}, stderr to $errors
 	exec {stdout}>&1
-	errors=$("${@}" 2>&1 1>&${stdout})
+	errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout})
 	ret=$?
 	exec {stdout}>&-
 
 	if [ "$errors" ]; then
-		printf "%s\n" "$errors" >&2
 		sig=$(grep 'terminating on signal' <<<"$errors")
 		if [ "$sig" ]; then
 			sig=$(sed 's/.*terminating on signal \([0-9][0-9]*\).*/\1/' <<<"$sig")
Signature · 1 line
2.10.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Radim Krčmář

Not doing so hid stderr output when the test was stuck and subsequently killed with ^C.

---
 scripts/arch-run.bash | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/arch-run.bash +0 -0
index 8e75c6ed6e17..326f59484e2b 100644

scripts/arch-run.bash run_qemu () · line 33

Quoted 5 lines
scripts/arch-run.bash +1 -1
@@ -30,12 +30,11 @@ run_qemu ()
 
 	# stdout to {stdout}, stderr to $errors
 	exec {stdout}>&1
-	errors=$("${@}" 2>&1 1>&${stdout})
+	errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout})

Lovely...

The comment above could have been changed to

 # ... stderr to stdout and $errors
Quoted 10 lines
scripts/arch-run.bash +0 -1
 	ret=$?
 	exec {stdout}>&-
 
 	if [ "$errors" ]; then
-		printf "%s\n" "$errors" >&2
 		sig=$(grep 'terminating on signal' <<<"$errors")
 		if [ "$sig" ]; then
 			sig=$(sed 's/.*terminating on signal \([0-9][0-9]*\).*/\1/' <<<"$sig")
Signature · 1 line
2.10.1
maintainer
#2 lore raw
Quoted 15 lines · Andrew Jones
Quoted 14 lines · Radim Krčmář

Not doing so hid stderr output when the test was stuck and subsequently killed with ^C.

---
 scripts/arch-run.bash | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/arch-run.bash +0 -0
index 8e75c6ed6e17..326f59484e2b 100644
@@ -30,12 +30,11 @@ run_qemu ()
 
Quoted 4 lines

scripts/arch-run.bash run_qemu () · line 33

Quoted 4 lines
scripts/arch-run.bash +1 -1
 	# stdout to {stdout}, stderr to $errors
 	exec {stdout}>&1
-	errors=$("${@}" 2>&1 1>&${stdout})
+	errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout})

What about:

# preserve stdout and stderr output, but save stderr to $errors
exec {stdout}>&1 {stderr}>&2
errors=$("$@" 2> >(tee /dev/fd/$stderr) > /dev/fd/$stdout)
exec {stdout}>&- {stderr}>&-

(Tested in the shell but not in arch-run.bash).

Paolo

Quoted 24 lines

Lovely...

The comment above could have been changed to

 # ... stderr to stdout and $errors
Quoted 10 lines
scripts/arch-run.bash +0 -1
 	ret=$?
 	exec {stdout}>&-
 
 	if [ "$errors" ]; then
-		printf "%s\n" "$errors" >&2
 		sig=$(grep 'terminating on signal' <<<"$errors")
 		if [ "$sig" ]; then
 			sig=$(sed 's/.*terminating on signal \([0-9][0-9]*\).*/\1/' <<<"$sig")
Signature · 1 line
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

2016-11-03 13:38+0100, Paolo Bonzini:

Quoted 23 lines · Andrew Jones
Quoted 15 lines · Radim Krčmář
Quoted 14 lines

Not doing so hid stderr output when the test was stuck and subsequently killed with ^C.

---
 scripts/arch-run.bash | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/arch-run.bash +0 -0
index 8e75c6ed6e17..326f59484e2b 100644
@@ -30,12 +30,11 @@ run_qemu ()
 
Quoted 4 lines

scripts/arch-run.bash run_qemu () · line 33

Quoted 4 lines
scripts/arch-run.bash +1 -1
 	# stdout to {stdout}, stderr to $errors
 	exec {stdout}>&1
-	errors=$("${@}" 2>&1 1>&${stdout})
+	errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout})

What about:

Quoted 6 lines
# preserve stdout and stderr output, but save stderr to $errors
exec {stdout}>&1 {stderr}>&2
errors=$("$@" 2> >(tee /dev/fd/$stderr) > /dev/fd/$stdout)
exec {stdout}>&- {stderr}>&-

(Tested in the shell but not in arch-run.bash).

Using files looks nicer, but is there a problem in the redirection? I would rather use /dev/stderr or /dev/fd/2 directly if not.

i.e.
exec {stdout}>&1
errors=$("$@" 2> >(tee /dev/stderr) > /dev/fd/$stdout) exec {stdout}>&-

maintainer
#4 lore raw
Quoted 31 lines · Radim Krčmář

2016-11-03 13:38+0100, Paolo Bonzini:

Quoted 23 lines · Andrew Jones
Quoted 15 lines · Radim Krčmář
Quoted 14 lines

Not doing so hid stderr output when the test was stuck and subsequently killed with ^C.

---
 scripts/arch-run.bash | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/arch-run.bash +0 -0
index 8e75c6ed6e17..326f59484e2b 100644
@@ -30,12 +30,11 @@ run_qemu ()
 
Quoted 4 lines

scripts/arch-run.bash run_qemu () · line 33

Quoted 4 lines
scripts/arch-run.bash +1 -1
 	# stdout to {stdout}, stderr to $errors
 	exec {stdout}>&1
-	errors=$("${@}" 2>&1 1>&${stdout})
+	errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout})

What about:

Quoted 6 lines
# preserve stdout and stderr output, but save stderr to $errors
exec {stdout}>&1 {stderr}>&2
errors=$("$@" 2> >(tee /dev/fd/$stderr) > /dev/fd/$stdout)
exec {stdout}>&- {stderr}>&-

(Tested in the shell but not in arch-run.bash).

Quoted 7 lines

Using files looks nicer, but is there a problem in the redirection? I would rather use /dev/stderr or /dev/fd/2 directly if not.

i.e.
exec {stdout}>&1
errors=$("$@" 2> >(tee /dev/stderr) > /dev/fd/$stdout) exec {stdout}>&-

Yes, this works too.

Paolo