#!/bin/sh ######################################################################## # Fedora Documentation Project Interactive Shell # # Runs BASH after first sourcing the "docs-common/bin/fdp-functions" # file. # # If the "-c cmd" switch is used, exactly one "cmd" is executed. # Without a "-c" switch, any file given on the command line is executed. # With neither a "-c" switch or command line arguments, commands are # accepted from stdin. ######################################################################## ME=`basename $0` USAGE="usage: ${ME} [-c cmd] [file [arg..]]" # Figure out absolute pathname to where we live FDPBINDIR=`dirname $0` case "${FDPBINDIR}" in /* ) ;; * ) FDPBINDIR=`/bin/pwd`/${FDPBINDIR};; esac # PATH=${FDPBINDIR}:${PATH} export PATH FDPDIR=`cd ${FDPBINDIR}/../.. ; /bin/pwd` export FDPDIR REALSHELL="${SHELL}" export REALSHELL SHELL=${FDPBINDIR}/${ME} export SHELL # FDPLOG=/tmp/fdpsh.log # . ${FDPBINDIR}/fdp-functions # CMD= while getopts c: c do case "${c}" in c) CMD="${OPTARG}";; *) echo "${USAGE}" >&2; exit 1;; esac done if [ "${CMD}" ]; then [ ! -f ${FDPLOG} ] || echo "${CMD}" >>${FDPLOG} eval "${CMD}" results=$? elif [ $# -gt 0 ]; then [ ! -f ${FDPLOG} ] || echo "${CMD}" >>${FDPLOG} eval $@ results=$? else while : do read -e -p "${ME}> " cmd if [ "${cmd}" ]; then [ ! -f ${FDPLOG} ] || echo "${CMD}" >>${FDPLOG} eval ${cmd} results=$? if [ ${results} -gt 0 ]; then echo "Status = ${results}" >&2 fi fi done fi exit ${results}