Skip to content

Commit

Permalink
Merge pull request #67 from ZOSOpenTools/dev_improvements
Browse files Browse the repository at this point in the history
Bash dev - test case fixes + signal OC4 patch
  • Loading branch information
IgorTodorovskiIBM authored Nov 22, 2023
2 parents d9f7abc + ff7fd98 commit 57d7010
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dev-patches/aclocal.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/aclocal.m4 b/aclocal.m4
index 26af88aa..66e7b3f1 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1576,15 +1576,15 @@ AC_DEFUN(BASH_CHECK_DEV_FD,
[AC_MSG_CHECKING(whether /dev/fd is available)
AC_CACHE_VAL(bash_cv_dev_fd,
[bash_cv_dev_fd=""
-if test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then
+if test "$host_os" = "openedition" && (exec test -r /dev/fd0 < /dev/null); then
+ bash_cv_dev_fd=nodir # /dev/fdN via character device
+elif test -d /dev/fd && (exec test -r /dev/fd/0 < /dev/null) ; then
# check for systems like FreeBSD 5 that only provide /dev/fd/[012]
if (exec test -r /dev/fd/3 3</dev/null) ; then
bash_cv_dev_fd=standard
else
bash_cv_dev_fd=absent
fi
-elif test "$host_os" = "openedition" && (exec test -r /dev/fd0 < /dev/null); then
- bash_cv_dev_fd=nodir # /dev/fdN via character device
fi
if test -z "$bash_cv_dev_fd" ; then
if test -d /proc/self/fd && (exec test -r /proc/self/fd/0 < /dev/null) ; then
64 changes: 64 additions & 0 deletions dev-patches/array.tests.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
diff --git a/tests/array.tests b/tests/array.tests
index b6d6c9cc..e6cddd6c 100644
--- a/tests/array.tests
+++ b/tests/array.tests
@@ -16,7 +16,7 @@
set +o posix

set +a
-# The calls to egrep -v are to filter out builtin array variables that are
+# The calls to grep -E -v are to filter out builtin array variables that are
# automatically set and possibly contain values that vary.

# first make sure we handle the basics
@@ -61,7 +61,7 @@ echo ${a[@]}
echo ${a[*]}

# this should print out values, too
-declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+declare -a | grep -E -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'

unset a[7]
echo ${a[*]}
@@ -92,11 +92,11 @@ echo ${a[@]}
readonly a[5]
readonly a
# these two lines should output `declare' commands
-readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
-declare -ar | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+readonly -a | grep -E -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+declare -ar | grep -E -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
# this line should output `readonly' commands, even for arrays
set -o posix
-readonly -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+readonly -a | grep -E -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
set +o posix

declare -a d='([1]="" [2]="bdef" [5]="hello world" "test")'
@@ -111,7 +111,7 @@ b=([0]=this [1]=is [2]=a [3]=test [4]="$PS1" [5]=$pass)

echo ${b[@]:2:3}

-declare -pa | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+declare -pa | grep -E -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'

a[3]="this is a test"

@@ -131,7 +131,7 @@ d=([1]="test test" [-65]=negative )
unset d[12]
unset e[*]

-declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+declare -a | grep -E -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'

ps1='hello'
unset ps1[2]
@@ -157,7 +157,7 @@ echo ${vv[0]} ${vv[3]}
echo ${vv[@]}
unset vv

-declare -a | egrep -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'
+declare -a | grep -E -v '(BASH_VERSINFO|PIPESTATUS|GROUPS)'

export rv
#set
17 changes: 17 additions & 0 deletions dev-patches/coproc.tests.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/tests/coproc.tests b/tests/coproc.tests
index a7359320..07651bf5 100644
--- a/tests/coproc.tests
+++ b/tests/coproc.tests
@@ -65,7 +65,11 @@ read <&${COPROC[0]}
echo $REPLY
echo ${COPROC[@]}

-cat /etc/passwd | grep root | awk -F: '{print $1;}' | sed 1q
+if [ -r "/etc/passwd" ]; then
+ cat /etc/passwd | grep root | awk -F: '{print $1;}' | sed 1q
+else
+ echo "root" # Some platforms do not have a /etc/passwd file
+fi

exec 4<&${COPROC[0]}-
exec >&${COPROC[1]}-
13 changes: 13 additions & 0 deletions dev-patches/redir.tests.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/tests/redir.tests b/tests/redir.tests
index a17da0fc..59f22af2 100644
--- a/tests/redir.tests
+++ b/tests/redir.tests
@@ -59,7 +59,7 @@ cat < $z

echo "Point 1"

-exec 3</etc/passwd
+exec 3</etc/profile
exec 4>$TMPDIR/bash-a
exec 5>$TMPDIR/bash-b
echo "Point 2"
File renamed without changes.
13 changes: 13 additions & 0 deletions dev-patches/source6.sub.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/tests/source6.sub b/tests/source6.sub
index 24372927..cdae2cbb 100644
--- a/tests/source6.sub
+++ b/tests/source6.sub
@@ -32,7 +32,7 @@ echo $?
echo $?

# pipe
-if [ -e /dev/stdin ]; then
+if /bin/test -e /dev/stdin; then
echo "echo three - OK" | . /dev/stdin
echo $?
else

0 comments on commit 57d7010

Please sign in to comment.