Allow multiple commands to be specified on a single command line, e.g.,

"portsnap fetch update" or "portsnap -I cron update".  They will be
executed in the order that they appear, and duplicates are not removed
(so "portsnap fetch fetch fetch fetch" is meaningful, albeit rather
silly).

Requested by:	Roman Divacky
This commit is contained in:
Colin Percival 2005-08-13 16:27:13 +00:00
parent 716b138b4b
commit d958d0d5dc
2 changed files with 11 additions and 7 deletions
usr.sbin/portsnap/portsnap

View File

@ -39,7 +39,7 @@
.Op Fl k Ar KEY
.Op Fl p Ar portsdir
.Op Fl s Ar server
.Cm command
.Cm command ...
.Op Ar path
.Sh DESCRIPTION
The

View File

@ -34,7 +34,7 @@
# --no-stats -- don't show progress statistics while fetching files
usage() {
cat <<EOF
usage: `basename $0` [options] command [path]
usage: `basename $0` [options] command ... [path]
Options:
-d workdir -- Store working files in workdir
@ -72,6 +72,7 @@ init_params() {
PORTSDIR=""
CONFFILE=""
COMMAND=""
COMMANDS=""
QUIETREDIR=""
QUIETFLAG=""
STATSREDIR=""
@ -132,19 +133,20 @@ parse_cmdline() {
shift; SERVERNAME="$1"
;;
cron | extract | fetch | update)
if [ ! -z "${COMMAND}" ]; then usage; fi
COMMAND="$1"
COMMANDS="${COMMANDS} $1"
;;
*)
if [ $# -gt 1 ]; then usage; fi
if [ "${COMMAND}" = "extract" ]; then usage; fi
if echo ${COMMANDS} | grep -vq extract; then
usage
fi
EXTRACTPATH="$1"
;;
esac
shift
done
if [ -z "${COMMAND}" ]; then
if [ -z "${COMMANDS}" ]; then
usage
fi
}
@ -906,4 +908,6 @@ cmd_update() {
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:${PATH}
get_params $@
cmd_${COMMAND}
for COMMAND in ${COMMANDS}; do
cmd_${COMMAND}
done