MAJOR=4
MINOR=50
DEVNAME=tty50
  7   cˆl–Ým_J	Å2Ž¥A3q·®2ê˜´o�þYd…Y·ä$h®¼Û@þé„"p_èÄæ 3Î    c#!/bin/sh
# $Id: texconfig-dialog.sh 53554 2020-01-26 23:58:37Z karl $
# texconfig-dialog
# Originally written by Thomas Esser. Public domain.
# Now maintained as part of TeX Live; correspondence to tex-live@tug.org.

# invoke the right shell:

test -f /bin/ksh && test -z "$RUNNING_KSH" \
  && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
  && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; }
unset RUNNING_KSH

test -f /bin/bsh && test -z "$RUNNING_BSH" \
  && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \
  && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; }
unset RUNNING_BSH

# hack around a bug in zsh:
test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'

# preferentially use subprograms from our own directory.
mydir=`echo "$0" | sed 's,/[^/]*$,,'`
mydir=`cd "$mydir" && pwd`
PATH="$mydir:$PATH"; export PATH

# the version string
version='$Id: texconfig-dialog.sh 53554 2020-01-26 23:58:37Z karl $'

: ${PAGER=more}
progname=texconfig-dialog
tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/tcdtmp.$$
log=$tmpdir/log
tmpmenu=$tmpdir/tmpmenu
needsCleanup=false

###############################################################################
# cleanup()
#   clean up the temp area and exit with proper exit status
###############################################################################
cleanup()
{
  rc=$1
  $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \
    && { cd / && rm -rf "$tmpdir"; }
  # use clear rather than reset since we cannot easily save and restore
  # the terminal settings, which is what would be ideal.  See thread
  # starting at http://tug.org/pipermail/tex-live/2016-March/037852.html.
  termCtl clear
  (exit $rc); exit $rc
}

###############################################################################
# setupTmpDir()
#   set up a temp directory and a trap to remove it
###############################################################################
setupTmpDir()
{
  case $needsCleanup in
    true) return;;
  esac

  trap 'cleanup 1' 1 2 3 7 13 15
  needsCleanup=true
  (umask 077; mkdir "$tmpdir") \
    || abort "could not create directory \`$tmpdir'"
}

###############################################################################
# abort(errmsg)
#   print `errmsg' to stderr and exit with error code 1
###############################################################################
abort()
{
  echo "$progname: $1." >&2
  cleanup 1
}

logexec()
{
  (echo; echo ">>> Executing \`$@' <<<") >> $log
  "$@" 2>&1 | tee -a $log
}

###############################################################################
# runDialog(args, ...)
#   execute the right dialog program with the right default parameters
###############################################################################
runDialog()
{
  if test -n "$DIALOG_PROG"; then
    termCtl clear
    $DIALOG_PROG --title "TeX setup utility" ${1+"$@"}
    runDialogRc=$?
    termCtl clear
  else
    abort "could not find dialog or whiptail program to run"
  fi
  (exit $runDialogRc)
  return $runDialogRc
}

###############################################################################
# findDialog(void)
#   set DIALOG_PROG to the system dialog program, or the empty string.
###############################################################################
findDialog()
{
  for bin in whiptail dialog
  do
    binLoc=`texconfig findprog $bin`
    case $binLoc in
      "") DIALOG_PROG="";;
      *)  DIALOG_PROG=$binLoc; break;;
    esac
  done
}

###############################################################################
# mktexdir(args)
#   call mktexdir script, disable all features (to prevent sticky directories)
###############################################################################
mktexdir()
{
  MT_FEATURES=none "$TEXMFMAIN/web2c/mktexdir" "$@" >&2
}

###############################################################################
# termCtl(arg)
#   some convenience utilities for 