File=table
Product=setterm

group:

    Flavor=ANY
    Qualifiers=""

common:

  ACTION=setup
    setupenv()
    #
    # If term isn't set at all, default to vt100
    #
    EnvSetIfNotSet(TERM,vt100)
    #
    # This is a condensation of the old login files...
    #
    Execute(stty sane, NO_UPS_ENV)
    Execute(stty echoe kill '^x' erase '^?' intr '^c', NO_UPS_ENV)
    Execute(/bin/sh -c '[ "$TERM" = "iris-ansi" -o "$TERM" = "iris-ansi-net" -o "$TERM" = "hp" ]' && stty erase '^h', NO_UPS_ENV)
    #
    # Now we stomp on the terminal type, unless the local terminfo has it
    #
    Execute(echo $TERM | cut -c1, NO_UPS_ENV, TTYPE)
    Execute(/bin/sh -c '[ -r /usr/lib/terminfo/$TTYPE/$TERM -o -r /usr/share/lib/terminfo/$TTYPE/$TERM ]' && echo $TERM || echo vt100, NO_UPS_ENV, TERM)
    EnvUnSet(TTYPE)
    #
    # Next we turn "network" "dumb", "sun" and other fictions into a
    # vt100 too
    #
    Execute(/bin/sh -c '[ "$TERM" = "network" -o "$TERM" = "dumb" -o "$TERM" = "sun" ]' && echo vt100 || echo $TERM, NO_UPS_ENV, TERM)
    #
    # Echo the terminal type, try to set the tty mode; but don't whine
    # if it fails...
    #
    Execute(echo Terminal type is ${TERM}, NO_UPS_ENV)
    Execute(sh -c 'chmod 622 `tty` >/dev/null 2>&1', NO_UPS_ENV)

end:

