diff options
author | Jim Meyering <jim@meyering.net> | 1994-10-05 00:43:46 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-10-05 00:43:46 +0000 |
commit | 33a89ddba58bc9518476e4bdf21d9db872352926 (patch) | |
tree | 5304e014098100f54908c8d388c0adf264623e7c /src | |
parent | 83577ddb4d0bb25c9badae452d1a456f9003a7b0 (diff) | |
download | coreutils-33a89ddba58bc9518476e4bdf21d9db872352926.tar.xz |
.
Diffstat (limited to 'src')
-rw-r--r-- | src/chmod.c | 30 | ||||
-rw-r--r-- | src/chown.c | 6 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/chmod.c b/src/chmod.c index 6a0ebb74c..17495cb6b 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -33,11 +33,12 @@ #include "safe-stat.h" #include "safe-lstat.h" +void error (); +void mode_string (); char *savedir (); +void strip_trailing_slashes (); char *xmalloc (); char *xrealloc (); -void error (); -void mode_string (); static int change_file_mode (); static int change_dir_mode (); @@ -166,7 +167,10 @@ main (argc, argv) error (1, 0, "virtual memory exhausted"); for (; optind < argc; ++optind) - errors |= change_file_mode (argv[optind], changes, 1); + { + strip_trailing_slashes (argv[optind]); + errors |= change_file_mode (argv[optind], changes, 1); + } exit (errors); } @@ -194,15 +198,17 @@ change_file_mode (file, changes, deref_symlink) } #ifdef S_ISLNK if (S_ISLNK (file_stats.st_mode)) - if (! deref_symlink) - return 0; - else - if (SAFE_STAT (file, &file_stats)) - { - if (force_silent == 0) - error (0, errno, "%s", file); - return 1; - } + { + if (! deref_symlink) + return 0; + else + if (SAFE_STAT (file, &file_stats)) + { + if (force_silent == 0) + error (0, errno, "%s", file); + return 1; + } + } #endif newmode = mode_adjust (file_stats.st_mode, changes); diff --git a/src/chown.c b/src/chown.c index b6e203177..3eac74a06 100644 --- a/src/chown.c +++ b/src/chown.c @@ -52,6 +52,7 @@ struct group *getgrgid (); char *savedir (); char *parse_user_spec (); +void strip_trailing_slashes (); char *xmalloc (); char *xrealloc (); void error (); @@ -159,7 +160,10 @@ main (argc, argv) username = ""; for (++optind; optind < argc; ++optind) - errors |= change_file_owner (argv[optind], user, group); + { + strip_trailing_slashes (argv[optind]); + errors |= change_file_owner (argv[optind], user, group); + } exit (errors); } |