-
Bug
-
Resolution: Duplicate
-
Undefined
-
None
-
rhel-8.8.0
-
None
-
Moderate
-
rhel-sst-cs-plumbers
-
ssg_core_services
-
None
-
False
-
-
None
-
None
-
None
-
None
-
If docs needed, set a value
-
-
All
-
None
Description of problem:
`bash -t` does not work on RHEL8.
It works on RHEL7 and earlier, and on RHEL9.
[root@rhel87 ~]# rpm -q bash
bash-4.4.20-4.el8_6.x86_64
[root@rhel87 ~]# bash -t <<< "echo hello"
[root@rhel87 ~]#
[root@rhel79 ~]# rpm -q bash
bash-4.2.46-34.el7.x86_64
[root@rhel79 ~]# bash -t <<< "echo hello"
hello
[root@rhel79 ~]#
[root@rhel92 ~]# rpm -q bash
bash-5.1.8-6.el9_1.x86_64
[root@rhel92 ~]# bash -t <<< "echo hello"
hello
[root@rhel92 ~]#
Version-Release number of selected component (if applicable):
- Red Hat Enterprise Linux 8
- bash-4.4.20-4.el8_6
How reproducible:
Always
Steps to Reproduce:
1. Run `bash -t <<< "echo hello"`
Actual results:
Nothing is displayed and sub-shell exits immediately.
Expected results:
"hello" will be displayed.
Additional info:
It seems to be a problem with the handling of tokens in the input.
In upstream, the following commit solved the problem.
--------------------------------------------------------------------
commit d233b485e83c3a784b803fb894280773f16f2deb (tag: bash-5.0)
Author: Chet Ramey <chet.ramey@case.edu>
Date: Mon Jan 7 09:27:52 2019 -0500
bash-5.0 distribution sources and documentation
:
+eval.c
+ - reader_loop: if we're just going to execute one command, make sure
+ the read-ahead token isn't set to something that will result in a
+ NULL command (by calling reset_readahead_token), since the code
+ will take that as the one command and set EOF_Reached
--------------------------------------------------------------------
It can be fixed by adding the following code extracted from bash-5.0.
--------------------------------------------------------------------
- cat bash-4.4-fix.patch
-
- a/eval.c 2023-08-25 11:35:52.304318084 +0900
+++ b/eval.c 2023-08-25 11:37:12.593570384 +0900
@@ -79,6 +79,9 @@ reader_loop ()
- a/eval.c 2023-08-25 11:35:52.304318084 +0900
-
our_indirection_level = ++indirection_level;
+ if (just_one_command)
+ reset_readahead_token ();
+
while (EOF_Reached == 0)
#endif
+void
+reset_readahead_token ()
+
+
static int
read_token_word (character)
int character;
--------------------------------------------------------------------
- impacts account
-
RHEL-5660 bash -t does not flush output
- Closed
- external trackers