Bug 426852

Summary: Lots of initscript bugs
Product: [Fedora] Fedora Reporter: Greg Turner <gmt>
Component: krb5Assignee: Nalin Dahyabhai <nalin>
Status: CLOSED RAWHIDE QA Contact: Brian Brock <bbrock>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: jplans
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: 1.6.3-4 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-01-02 12:04:36 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Greg Turner 2007-12-27 07:32:51 EST
Description of problem:
Consider the following buggy code:

# x=no [ $x = "no" ] || echo yes
-bash: [: =: unary operator expected

Similar errors are suprisingly pervasive in rhel5 and 4.  Install rpms and run 

find /etc -type f | xargs grep
'\[[[:space:]]*\${[^}]*\}[[:space:]]*=[[:space:]]*\".*\".*]' -C 2 -n --color=yes

for a nice list.

This is probably a big part of why my console is littered with stderr instead of
nice pretty green "OK" symbols during boot.

Version-Release number of selected component (if applicable):
at least rhel4 and 5.

Steps to Reproduce:
1.install, i.e., el4 krb5-server
2 run any init script from this package
3.read output on stderr
Actual results:
[: =: unary operator expected

Expected results:

Additional info:

Adding quotes around the shell var. gives apples<->apples comparison fixing problem.

Tested only on CentOS.
Comment 1 Greg Turner 2007-12-27 07:44:45 EST
oops, here is an improved version of the above script that catches more bugs:

find /etc -type f | xargs grep '\[[[:space:]]*\$[^\"]*=[[:space:]]*\".*\".*]' -C
2 -n --color=yes
Comment 2 Greg Turner 2007-12-28 17:34:46 EST
FYI I have confirmed that replacing, ie [ $foo = "bar" ] with [ "$foo" = "bar" ]
in all initscripts makes the (serial console) boot sequence pretty again.  Glad
to see fixing the bug does not seem to have broken my server in any noticable way :)
Comment 3 Nalin Dahyabhai 2008-01-02 11:41:39 EST
The instances which the grep catches (thanks for that) seem to have been fixed
for RHEL as part of bug #242500, so I'm moving this to Fedora development, which
hasn't had those changes merged, so that I don't forget to get them in for F9.