From owner-svn-src-all@FreeBSD.ORG Sat Jan 30 06:49:19 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 12CCC1065670; Sat, 30 Jan 2010 06:49:19 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 01A0A8FC0C; Sat, 30 Jan 2010 06:49:19 +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 o0U6nIjP014178; Sat, 30 Jan 2010 06:49:18 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0U6nIRv014174; Sat, 30 Jan 2010 06:49:18 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <201001300649.o0U6nIRv014174@svn.freebsd.org> From: Tim Kientzle Date: Sat, 30 Jan 2010 06:49:18 +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: r203183 - head/usr.bin/cpio X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jan 2010 06:49:19 -0000 Author: kientzle Date: Sat Jan 30 06:49:18 2010 New Revision: 203183 URL: http://svn.freebsd.org/changeset/base/203183 Log: Support -V option to print a dot for each file processed. Also, change the existing -vi behavior to send the filenames to stderr rather than stdout, as GNU cpio does. PR: bin/141175 Submitted by: Philip Kizer MFC after: 14 days Modified: head/usr.bin/cpio/cmdline.c head/usr.bin/cpio/cpio.c head/usr.bin/cpio/cpio.h Modified: head/usr.bin/cpio/cmdline.c ============================================================================== --- head/usr.bin/cpio/cmdline.c Sat Jan 30 06:23:28 2010 (r203182) +++ head/usr.bin/cpio/cmdline.c Sat Jan 30 06:49:18 2010 (r203183) @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$"); /* * Short options for cpio. Please keep this sorted. */ -static const char *short_options = "0AaBC:F:O:cdE:f:H:hijLlmnopR:rtuvW:yZz"; +static const char *short_options = "0AaBC:F:O:cdE:f:H:hijLlmnopR:rtuvVW:yZz"; /* * Long options for cpio. Please keep this sorted. @@ -61,6 +61,7 @@ static const struct option { int equivalent; /* Equivalent short option. */ } cpio_longopts[] = { { "create", 0, 'o' }, + { "dot", 0, 'V' }, { "extract", 0, 'i' }, { "file", 1, 'F' }, { "format", 1, 'H' }, Modified: head/usr.bin/cpio/cpio.c ============================================================================== --- head/usr.bin/cpio/cpio.c Sat Jan 30 06:23:28 2010 (r203182) +++ head/usr.bin/cpio/cpio.c Sat Jan 30 06:49:18 2010 (r203183) @@ -278,6 +278,9 @@ main(int argc, char *argv[]) case 'v': /* POSIX 1997 */ cpio->verbose++; break; + case 'V': /* GNU cpio */ + cpio->dot++; + break; case OPTION_VERSION: /* GNU convention */ version(); break; @@ -331,6 +334,9 @@ main(int argc, char *argv[]) /* -l requires -p */ if (cpio->option_link && cpio->mode != 'p') cpio_errc(1, 0, "Option -l requires -p"); + /* -v overrides -V */ + if (cpio->dot && cpio->verbose) + cpio->dot = 0; /* TODO: Flag other nonsensical combinations. */ switch (cpio->mode) { @@ -388,7 +394,7 @@ static const char *long_help_msg = "First option must be a mode specifier:\n" " -i Input -o Output -p Pass\n" "Common Options:\n" - " -v Verbose\n" + " -v Verbose filenames -V one dot per file\n" "Create: %p -o [options] < [list of files] > [archive]\n" #ifdef HAVE_BZLIB_H " -y Compress archive with bzip2\n" @@ -521,6 +527,8 @@ mode_out(struct cpio *cpio) } r = archive_write_close(cpio->archive); + if (cpio->dot) + fprintf(stderr, "\n"); if (r != ARCHIVE_OK) cpio_errc(1, 0, archive_error_string(cpio->archive)); @@ -659,6 +667,8 @@ entry_to_archive(struct cpio *cpio, stru /* Print out the destination name to the user. */ if (cpio->verbose) fprintf(stderr,"%s", destpath); + if (cpio->dot) + fprintf(stderr, "."); /* * Option_link only makes sense in pass mode and for @@ -857,7 +867,9 @@ mode_in(struct cpio *cpio) if (destpath == NULL) continue; if (cpio->verbose) - fprintf(stdout, "%s\n", destpath); + fprintf(stderr, "%s\n", destpath); + if (cpio->dot) + fprintf(stderr, "."); if (cpio->uid_override >= 0) archive_entry_set_uid(entry, cpio->uid_override); if (cpio->gid_override >= 0) @@ -872,6 +884,8 @@ mode_in(struct cpio *cpio) } } r = archive_read_close(a); + if (cpio->dot) + fprintf(stderr, "\n"); if (r != ARCHIVE_OK) cpio_errc(1, 0, archive_error_string(a)); r = archive_write_close(ext); @@ -1078,6 +1092,8 @@ mode_pass(struct cpio *cpio, const char archive_entry_linkresolver_free(cpio->linkresolver); r = archive_write_close(cpio->archive); + if (cpio->dot) + fprintf(stderr, "\n"); if (r != ARCHIVE_OK) cpio_errc(1, 0, archive_error_string(cpio->archive)); Modified: head/usr.bin/cpio/cpio.h ============================================================================== --- head/usr.bin/cpio/cpio.h Sat Jan 30 06:23:28 2010 (r203182) +++ head/usr.bin/cpio/cpio.h Sat Jan 30 06:49:18 2010 (r203183) @@ -52,6 +52,7 @@ struct cpio { const char *format; /* -H format */ int bytes_per_block; /* -b block_size */ int verbose; /* -v */ + int dot; /* -V */ int quiet; /* --quiet */ int extract_flags; /* Flags for extract operation */ char symlink_mode; /* H or L, per BSD conventions */