From owner-svn-src-head@FreeBSD.ORG Wed Dec 30 06:28:48 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CAF510657E5; Wed, 30 Dec 2009 06:28:48 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4CB0A8FC45; Wed, 30 Dec 2009 06:28:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBU6SlTm049263; Wed, 30 Dec 2009 06:28:47 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBU6Slrn049261; Wed, 30 Dec 2009 06:28:47 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <200912300628.nBU6Slrn049261@svn.freebsd.org> From: Colin Percival Date: Wed, 30 Dec 2009 06:28:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201251 - head/usr.sbin/portsnap/portsnap X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Dec 2009 06:28:48 -0000 Author: cperciva Date: Wed Dec 30 06:28:47 2009 New Revision: 201251 URL: http://svn.freebsd.org/changeset/base/201251 Log: Add undocumented 'portsnap alfred' command, which runs (fetch|cron) based on whether fd 0 is a terminal, and then runs (extract|update) based on whether ${PORTSDIR} exists. Requested by: alfred MFC after: 1 month Modified: head/usr.sbin/portsnap/portsnap/portsnap.sh Modified: head/usr.sbin/portsnap/portsnap/portsnap.sh ============================================================================== --- head/usr.sbin/portsnap/portsnap/portsnap.sh Wed Dec 30 06:28:30 2009 (r201250) +++ head/usr.sbin/portsnap/portsnap/portsnap.sh Wed Dec 30 06:28:47 2009 (r201251) @@ -140,7 +140,7 @@ parse_cmdline() { if [ ! -z "${SERVERNAME}" ]; then usage; fi shift; SERVERNAME="$1" ;; - cron | extract | fetch | update) + cron | extract | fetch | update | alfred) COMMANDS="${COMMANDS} $1" ;; *) @@ -1040,6 +1040,22 @@ cmd_update() { update_run || exit 1 } +# Alfred command. Run 'fetch' or 'cron' depending on +# whether stdin is a terminal; then run 'update' or +# 'extract' depending on whether ${PORTSDIR} exists. +cmd_alfred() { + if [ -t 0 ]; then + cmd_fetch + else + cmd_cron + fi + if [ -d ${PORTSDIR} ]; then + cmd_update + else + cmd_extract + fi +} + #### Entry point # Make sure we find utilities from the base system