Opened 12 years ago

Closed 12 years ago

#154 closed defect (fixed)

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

Reported by: cummings Owned by: bruno
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 Changed 12 years ago by bruno

  • Milestone set to 2.2.3
  • Status changed from new to assigned
  • Wiki fixed
  • mindi fixed in rev [1342] to be POSIX clean for dash on Ubuntu (will be in 2.2.3)

comment:2 Changed 12 years ago by bruno

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.