Posssible problem with new Bourne shell in Redhat 6.2?
Hello,
the /bin/sh in RHEL 6 seems to have a different behaviour now than in earlier releases. While previous versions of /bin/sh accepted negative arguments to the built-in "return", this no longer seems to be the case with current /bin/sh in RHEL 6.2:
RHEL 5.3: [root@rhel5 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.3 (Tikanga) [root@rhel5 ~]# rpm -qf /bin/sh bash-3.2-24.el5 [root@rhel5 ~]# /bin/sh sh-3.2# d() { return -1; } sh-3.2# d sh-3.2# echo $? 255 RHEL 6.2: [root@rhel6 ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.2 (Santiago) [root@rhel6 ~]# rpm -qf /bin/sh bash-4.1.2-8.el6.x86_64 [root@rhel6 ~]# /bin/sh sh-4.1# d() { return -1; } sh-4.1# d sh: return: -1: Ungültige Option return: Gebrauch: return [n] sh-4.1# echo $? 2
The problem is that many shell scripts in Storage Foundation for Linux seem to use 'return -1', e.g. vxadm_syslib.sh. So this new behaviour potentially breaks Storage Foundation scripts.
[root@rhel6 lib]# grep 'return -1' /usr/lib/vxvm/voladm.d/lib/vxadm_syslib.sh | wc -l 13
POSIX norm requires unsigned decimal integer as a return value: http://pubs.opengroup.org/onlinepubs/009695399/utilities/return.html, so the new behaviour seems to be correct. E.g. Solaris:
sol10> /bin/sh sol10> d() { return -1; } sol10> d -1: bad number sol10> echo $? 1
I tested this with SF 6.0SP1.
A potential fix could be to replace 'return -1' with 'return 255'.
Is there a patch that fixes this?