Date: Sat, 30 Jan 2010 06:49:18 +0000 (UTC) From: Tim Kientzle <kientzle@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r203183 - head/usr.bin/cpio Message-ID: <201001300649.o0U6nIRv014174@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001300649.o0U6nIRv014174>