Opened 18 years ago

Closed 18 years ago

#154 closed defect (fixed)

Troubleshooting with sh -x and Ubuntu, Replace == for stricter POSIX conformance with =

Reported by: Scott Cummings Owned by: Bruno Cornec
Priority: normal Milestone: 2.2.3
Component: mindi Version: 2.2.2
Severity: minor Keywords:
Cc:

Description

Would be academic except for these circumstances -

  1. Ubuntu - which points sh to /bin/dash (https://wiki.ubuntu.com/DashAsBinSh) together with
  1. http://trac.mondorescue.org/wiki/TroubleShooting - Trouble-Shooting mindi

Using sh -x /usr/sbin/mindi 2>&1 gives different results than mindi by itself.

example:

$ ./fragment
TMPMODPROBE_FLAG=Y
$ sh -x ./fragment  2>&1 
+ [ -d /etc/modprobe.d ]
+ cut -c1-3
+ uname -r
+ [ 2.6 == 2.6 ]
[: 1: ==: unexpected operator
+ echo TMPMODPROBE_FLAG=N
TMPMODPROBE_FLAG=N

(Yes, if one is observant one see the 'unexpected operator' message, but the script continues to run, so I was surprised by the result.)

$ cat fragment
#!/bin/bash 
# Test mindi fragment under debug - sh -x 
if [ -d "/etc/modprobe.d" ] && [ `uname -r | cut -c1-3` == "2.6" ] ; then
        echo TMPMODPROBE_FLAG="Y"
else
        echo TMPMODPROBE_FLAG="N"
fi

If the == is changed to = then the result is -

$ sh -x ./fragment  2>&1 
+ [ -d /etc/modprobe.d ]
+ uname -r
+ cut -c1-3
+ [ 2.6 = 2.6 ]
+ echo TMPMODPROBE_FLAG=Y
TMPMODPROBE_FLAG=Y

Of course, this could be solved also by changing to -

$ bash -x ./fragment  2>&1 
+ '[' -d /etc/modprobe.d ']'
++ uname -r
++ cut -c1-3
+ '[' 2.6 == 2.6 ']'
+ echo TMPMODPROBE_FLAG=Y
TMPMODPROBE_FLAG=Y

So maybe the troubleshooting tip should have bash -x /usr/sbin/mindi 2>&1 ?

Regards,

Scott

Change History (2)

comment:1 by Bruno Cornec, 18 years ago

Milestone: 2.2.3
Status: newassigned
  • Wiki fixed
  • mindi fixed in rev [1342] to be POSIX clean for dash on Ubuntu (will be in 2.2.3)

comment:2 by Bruno Cornec, 18 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.