#!/bin/ksh -p
# $Id: //depot/stable/explorer/tools/cmdline#2 $
#
# Explorer Version:
EXP_VERSION=4.0
#

# Source tools functions
. ${EXP_LIB}/exp_tools

# scoop up any extra commands or files specified on the command line
if [ -n "${EXP_EXTRA_FILES}" ]
then
    # logfile NOTNOISE "Collecting command line files"
    TEXT=`gettext "Collecting command line files"`
    logfile NOTNOISE "${TEXT}"
    for FILE in `echo ${EXP_EXTRA_FILES} | sed -e 's/,/ /g'`
    do
	get_file "${FILE}"
    done
fi

if [ -n "${EXP_EXTRA_CMDS}" ]
then
    # logfile NOTNOISE "Collecting command line commands"
    TEXT=`gettext "Collecting command line commands"`
    logfile NOTNOISE "${TEXT}"
    for EXE in `echo ${EXP_EXTRA_CMDS} | sed -e 's/,/ /g'`
    do
	# Translate %20 back to spaces
	COMMAND="`echo ${EXE} | sed -e 's/%20/ /g'`"

	# Do a quick check for full path to command
	echo "${COMMAND}" | egrep -s -e "^\/"
	if [ "$?" -ne 0 ]
	then
	    echo "${COMMAND}" | egrep -s -e " "
	    if [ "$?" -eq 0 ]
	    then
		CMD=`echo "${COMMAND}" | nawk '{ print $1 }'`
	    else
		CMD="${COMMAND}"
	    fi

	    # logfile ERROR "Please use the full path for command '${CMD}'"
	    TEXT=`gettext "Please use the full path for command '%s'"`
	    TEXT=`printf "${TEXT}" "${CMD}"`
	    logfile ERROR "${TEXT}"
	    continue
	fi

	get_cmd "${COMMAND}"
    done
fi
