Technical article 104872

In OpenServer Release 5, the more(C) doesn't understand escape sequences

OpenServer 5.0.0

Written · Last revised

Problem

The "more" command in SCO OpenServer Release 5.0.0 was derived
from the BSD4.4 source, plus modifications to support POSIX.2
and XPG4.  It is new source for SCO.  The new more(C) interprets
all control characters and displays them instead of ignoring them
and passing them.  As a side effect, DOS files that have "\r"
will show up as ^M instead of just passing the values through.

To see an example of this problem, pipe the output of the setcolor(C) program, which uses escape lead-in sequences to change the screen color, to more(C):

setcolor | more
or
setcolor | more -v

In SCO OpenServer Release 5.0.0, the output is identical. more(C) does not differentiate the input from setcolor(C). In SCO Open Desktop Release 3.0, more(C) would show different output in either case.

Solution

Here is a sample program that works in SCO Open Desktop 3.0
version of more(C).  Following this example is the same program
modified for SCO OpenServer Release 5.0.0.
#!/bin/sh
#==============================================================================
#
echo=/bin/echo
ESC=`$echo "\033\c"`
BK2=`$echo "\010\010\c"`
if [ "$TERM" = "ansi" -o "$TERM" = "pansi" ]
then
   _e="${ESC}[1;31;40m"              # Error text (red)
   _h="${ESC}[1;32;40m"              # Highlighted text (green on black)
   _w="${ESC}[1;36;40m"              # Warning text (cyan on black)
   _n="${ESC}[0;37;40m"              # Normal text (white on black)
else
   _e=
   _n=
   _h=
   _w=
fi
UNAME=`uname`
uname()
{
   echo " " >/tmp/$$.out
   echo "ERROR:${_e} $UNAME ${_n} " >>/tmp/$$.out
   echo "cat /tmp/$$.out | more"
   cat /tmp/$$.out | more
   echo "cat /tmp/$$.out | more -v"
   cat /tmp/$$.out | more -v
   echo "cat /tmp/$$.out | pg"
   cat /tmp/$$.out |pg
}
# Debug flag
#set -x
uname
exit
Below is a work around for the more(C) command.  It passes
the 8 bit sequences successfully.  So instead of ESC[,
use the 0x9b or \0233 sequence.
#!/bin/sh
#==============================================================================
#
echo=/bin/echo
# use the 0x9b or 0233   8 bit escape sequence.
ESC=`$echo "\0233\c"`
BK2=`$echo "\010\010\c"`
if [ "$TERM" = "ansi" -o "$TERM" = "pansi" ]
then
   _e="${ESC}=4F"               # Error text (red)
#  _e="${ESC}[=4F"              # Error text (red)
#  _e="${ESC}[1;31;40m"         # Error text (red)
   _h="${ESC}[1;32;40m"         # Highlighted text (green on black)
   _w="${ESC}[1;36;40m"         # Warning text (cyan on black)
# _n="${ESC}[0;37;40m"          # Normal text (white on black)
# _n="${ESC}[=7F${ESC}[=0G"     # Normal text (white on black)
  _n="${ESC}=7F${ESC}[=0G"      # Normal text (white on black)
else
   _e=
   _n=
   _h=
   _w=
fi
UNAME=`uname`
uname()
{
   echo " " /tmp/$$.out
   echo "ERROR:${_e} $UNAME ${_n} " >/tmp/$$.out
   echo "cat /tmp/$$.out | more"
   cat /tmp/$$.out | more
   echo "cat /tmp/$$.out | more -v"
   cat /tmp/$$.out | more -v
   echo "cat /tmp/$$.out | pg"
   cat /tmp/$$.out |pg
}
# Debug flag
#set -x
uname
exit

From the Xinuos technical article database, record 104872. Reproduced with permission. The original is at www.sco.com/ta/104872, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.