diff options
author | kientzle <kientzle@FreeBSD.org> | 2010-01-30 06:49:18 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2010-01-30 06:49:18 +0000 |
commit | 9bb67338d90f67516f98049144a17950c8013a19 (patch) | |
tree | b1eac02134794fd6b879bed90fdd3ba3484b2d85 | |
parent | 89690f20ef8083eee2b717d7421d5cb4f470fe47 (diff) | |
download | FreeBSD-src-9bb67338d90f67516f98049144a17950c8013a19.zip FreeBSD-src-9bb67338d90f67516f98049144a17950c8013a19.tar.gz |
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
-rw-r--r-- | usr.bin/cpio/cmdline.c | 3 | ||||
-rw-r--r-- | usr.bin/cpio/cpio.c | 20 | ||||
-rw-r--r-- | usr.bin/cpio/cpio.h | 1 |
3 files changed, 21 insertions, 3 deletions
diff --git a/usr.bin/cpio/cmdline.c b/usr.bin/cpio/cmdline.c index 9b61728..b6a56be 100644 --- a/usr.bin/cpio/cmdline.c +++ b/usr.bin/cpio/cmdline.c @@ -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' }, diff --git a/usr.bin/cpio/cpio.c b/usr.bin/cpio/cpio.c index 3b626f7..53195aa 100644 --- a/usr.bin/cpio/cpio.c +++ b/usr.bin/cpio/cpio.c @@ -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, struct archive_entry *entry) /* 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 *destdir) 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)); diff --git a/usr.bin/cpio/cpio.h b/usr.bin/cpio/cpio.h index 84932992..8c18737 100644 --- a/usr.bin/cpio/cpio.h +++ b/usr.bin/cpio/cpio.h @@ -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 */ |