ksh: fix up shipin for more modern systems WRT test and wc
authorJon Trulson <jon@radscan.com>
Sun, 22 Nov 2015 22:37:40 +0000 (15:37 -0700)
committerJon Trulson <jon@radscan.com>
Sun, 22 Nov 2015 22:37:40 +0000 (15:37 -0700)
Patch submitted by Giacomo Comes.

cde/programs/dtksh/ksh93/ship/shipin

index e91dbf2603d6a13ebaf571655ef953376a699c58..66c22b638f913a501659a9556445a662caceef82 100755 (executable)
@@ -64,6 +64,9 @@ case $- in
        ;;
 esac
 
+# disable the builtin wc because ksh may hang during the execution later of "wc pic.o"
+builtin -d wc
+
 #
 # this script may be overwritten while it is being executed
 # so copy it and exec from the copy
@@ -569,7 +572,8 @@ do  case $1 in
                eval _ship${_cmd_}_=
                continue
        fi
-       if      test "$new" -gt "$old"
+       # the variable "old" can be empty, to avoid "arithmetic syntax error" from ksh, set it to 0
+       if      test "$new" -gt "${old:-0}"
        then    case $_suf_ in
                ?*)     cp ship$_cmd_$_suf_ SHIP$_cmd_$_suf_ ;;
                esac
@@ -583,7 +587,8 @@ do  case $1 in
                case $_suf_ in
                .c)     test -f $f && ./$f </dev/null >/dev/null 2>&1 || old=0 ;;
                esac
-               if      test "$new" -gt "$old"
+               # the variable "old" can be empty, to avoid "arithmetic syntax error" from ksh, set it to 0
+               if      test "$new" -gt "${old:-0}"
                then    case $old in
                        ""|0)   ;;
                        *)      cp ship$_cmd_ SHIP$_cmd_ ;;
@@ -612,7 +617,8 @@ do  case $1 in
        esac
        case $_flg_ in
        *B*)    f=$BIN/$_cmd_; eval old=$_stamp_
-               if      test "$new" -gt "$old"
+               # the variable "old" can be empty, to avoid "arithmetic syntax error" from ksh, set it to 0
+               if      test "$new" -gt "${old:-0}"
                then    if      test ! -d $BIN
                        then    mkdir $BIN
                        fi