Skip to main content
Add more references and possible hints at further problems.
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

The problemOne issue is that you are using a string comparison operator (>). This operator will check if the left-hand-side string is lexicographicallylexicographically greater than the right-hand-side string.

What you instead need toshould use is the arithmetic comparison operator -gt. The same is true for your checks of the return codes, where you should use -eq instead (although it is less of a problem there, the strings representing the two numbers will be equal if the numbers themselves are).

See e.g. here or here for more information.

That said, in the simple case of a one-digit number (REBOOT_REQUIRED should not be able to exceed 2) compared to the "one-digit string" 0 the comparison should still work as expected, so there may be something amiss in the subordinate scripts you call.

The problem is that you are using a string comparison operator (>). This operator will check if the left-hand-side string is lexicographically greater than the right-hand-side string.

What you instead need to use is the arithmetic comparison operator -gt.

See e.g. here for more information.

One issue is that you are using a string comparison operator (>). This operator will check if the left-hand-side string is lexicographically greater than the right-hand-side string.

What you instead should use is the arithmetic comparison operator -gt. The same is true for your checks of the return codes, where you should use -eq instead (although it is less of a problem there, the strings representing the two numbers will be equal if the numbers themselves are).

See e.g. here or here for more information.

That said, in the simple case of a one-digit number (REBOOT_REQUIRED should not be able to exceed 2) compared to the "one-digit string" 0 the comparison should still work as expected, so there may be something amiss in the subordinate scripts you call.

Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

The problem is that you are using a string comparison operator (>). This operator will check if the left-hand-side string is lexicographically greater than the right-hand-side string.

What you instead need to use is the arithmetic comparison operator -gt.

See e.g. here for more information.