aboutsummaryrefslogtreecommitdiff
path: root/bin/chmod
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>2002-08-04 05:29:13 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>2002-08-04 05:29:13 +0000
commit30d90946d1f49812bab2a4f6488a76b6aa6fd7d1 (patch)
tree2450b138d4b71f55121d7eefa21f6c08479c37a2 /bin/chmod
parentb985a624a30e82ab218877796d2ae838320d54db (diff)
downloadsrc-30d90946d1f49812bab2a4f6488a76b6aa6fd7d1.tar.gz
src-30d90946d1f49812bab2a4f6488a76b6aa6fd7d1.zip
Allow "-v -v" to mean very verbose.
Reviewed by: freebsd-standards PR: 40709 Submitted by: Edward Brocklesby <nighthawk@unrealircd.com>, johan
Notes
Notes: svn path=/head/; revision=101297
Diffstat (limited to 'bin/chmod')
-rw-r--r--bin/chmod/chmod.15
-rw-r--r--bin/chmod/chmod.c22
2 files changed, 23 insertions, 4 deletions
diff --git a/bin/chmod/chmod.1 b/bin/chmod/chmod.1
index 2b0a85028672..b24a82dabd35 100644
--- a/bin/chmod/chmod.1
+++ b/bin/chmod/chmod.1
@@ -86,7 +86,10 @@ rather than the file that the link points to.
.It Fl v
Cause
.Nm
-to be verbose, showing files as the mode is modified.
+to be verbose, showing filenames as the mode is modified. If the
+.Fl v
+flag is specified more than once, the old and new modes of the file
+will also be printed, in both octal and symbolic notation.
.El
.Pp
The
diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c
index 2cc37d8002b6..5014d43ea70b 100644
--- a/bin/chmod/chmod.c
+++ b/bin/chmod/chmod.c
@@ -121,7 +121,7 @@ main(int argc, char *argv[])
--optind;
goto done;
case 'v':
- vflag = 1;
+ vflag++;
break;
case '?':
default:
@@ -208,8 +208,24 @@ done: argv += optind;
warn("%s", p->fts_path);
rval = 1;
} else {
- if (vflag)
- (void)printf("%s\n", p->fts_accpath);
+ if (vflag) {
+ (void)printf("%s", p->fts_accpath);
+
+ if (vflag > 1) {
+ char m1[12], m2[12];
+
+ strmode(p->fts_statp->st_mode, m1);
+ strmode((p->fts_statp->st_mode &
+ S_IFMT) | newmode, m2);
+
+ (void)printf(": 0%o [%s] -> 0%o [%s]",
+ p->fts_statp->st_mode, m1,
+ (p->fts_statp->st_mode & S_IFMT) |
+ newmode, m2);
+ }
+ (void)printf("\n");
+ }
+
}
}
if (errno)