0

Hi I tried to use this version compare function provided compare-two-strings-in-version format but I am having problem with SunOS 5.10 sun4v when comparing unequal strings like 1.22 and 1.21 compver.sh: line 55: 10#(1.21) > 10#(1.22): syntax error in expression (error token is "(1.21) > 10#(1.22)") compver.sh: line 59: 10#(1.21) < 10#(1.22): syntax error in expression (error token is "(1.21) < 10#(1.22)")

This same script works fine in Linux (Linux 2.6.32-431.1.2.el6.x86_64 x86_64).

Thanks in advance

Community
  • 1
  • 1
  • 1
    You probably need Bash or a newer version of it. – konsolebox Jun 12 '14 at 12:21
  • What do you get with `bash --version`? – konsolebox Jun 12 '14 at 12:25
  • Thanks @konsolebox for getting back to me. The version on SunOS is bash-3.00$ bash --version GNU bash, version 3.00.16(1)-release (sparc-sun-solaris2.10) Copyright (C) 2004 Free Software Foundation, Inc. While on the Linux box is GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. – user3729750 Jun 13 '14 at 15:50
  • Obviously the versions are far apart and sunOS is much older. Do you think upgrading the bash in sunOS will fix it before informing our infrastructure team to do so. Thanks in advance – user3729750 Jun 13 '14 at 15:55
  • I have most versions of Bash installed and I can test your script. Mind updating your post with the crucial part of it? – konsolebox Jun 13 '14 at 15:55
  • Thanks @konsolebox, as I said, I was using the vercomp function provided in another post, see the link above. The offending part in sunOS is given below – user3729750 Jun 13 '14 at 22:37
  • `if ((10#${ver1[i]} > 10#${ver2[i]})) then return 1 fi if ((10#${ver1[i]} < 10#${ver2[i]})) then return 2 fi` – user3729750 Jun 13 '14 at 22:39
  • Sorry about the formatting! – user3729750 Jun 13 '14 at 22:47
  • Just made the test. It doesn't work with Bash 3.0 but works with 3.1.1 and newer versions. So you have to have a newer version of Bash. – konsolebox Jun 14 '14 at 15:37
  • Thanks, I will upgrade to that version or higher and let you know if it works me too. – user3729750 Jun 16 '14 at 08:36

0 Answers0