bug-bash
[Top][All Lists]
Advanced

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

Procsub.tests on OSes using named pipes


From: CHIGOT, CLEMENT
Subject: Procsub.tests on OSes using named pipes
Date: Thu, 13 Feb 2020 10:00:23 +0000

Hi, 

procsub.tests is failing on OSes using named pipes (like AIX). 
As far as I understand, with named pipes, the temporary file (sh-np*) is 
suppressed once it has been read, therefore every attempts to read the same 
input will fail with ENOENT. It seems to be the case in "count_lines" function. 
However, the handler for named pipes has been commented and I haven't found 
why. Is there any reason behind that ? If no, here is a patch fixing 
procsub.tests.

----


[PATCH] tests: fix procsubs tests on OSes using named pipes

On OSes using named pipes (like AIX), the pipe's file is suppressed
after the first read. Thus every commands trying to read it afterwards
will fail with ENOENT errno.
---
 tests/procsub.tests | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/procsub.tests b/tests/procsub.tests
index 01ba46a8..22f43b83 100644
--- a/tests/procsub.tests
+++ b/tests/procsub.tests
@@ -69,10 +69,12 @@ count_lines()
 {
     wc -l < $1

-#    case "$1" in
-#    *sh-np*)  [ -e "$1" ] || { echo 0; echo 0; echo 0; echo 0; return; } ;;
-#    *) ;;
-#    esac
+    # For OSes using named pipes, $1 will be deleted after the first read and
+    # thus ENOENT error will be returned for every following commands.
+    case "$1" in
+    *sh-np*)    [ -e "$1" ] || { echo 0; echo 0; echo 0; echo 0; return; } ;;
+    *) ;;
+    esac

     wc -l < $1
     wc -l < $1
@@ -88,6 +90,10 @@ echo extern
 FN=$TMPDIR/bashtest-$$
 cat >$FN << \EOF
 wc -l < $1
+case "$1" in
+*sh-np*)    [ -e "$1" ] || { echo 0; echo 0; echo 0; echo 0; return; } ;;
+*) ;;
+esac
 wc -l < $1
 wc -l < $1
 true | wc -l < $1
-- 
2.17.1





Clément Chigot

ATOS Bull SAS
1 rue de Provence - 38432 Échirolles - France




reply via email to

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