summaryrefslogtreecommitdiff
path: root/src/chmod.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-10-05 00:43:46 +0000
committerJim Meyering <jim@meyering.net>1994-10-05 00:43:46 +0000
commit33a89ddba58bc9518476e4bdf21d9db872352926 (patch)
tree5304e014098100f54908c8d388c0adf264623e7c /src/chmod.c
parent83577ddb4d0bb25c9badae452d1a456f9003a7b0 (diff)
downloadcoreutils-33a89ddba58bc9518476e4bdf21d9db872352926.tar.xz
.
Diffstat (limited to 'src/chmod.c')
-rw-r--r--src/chmod.c30
1 files changed, 18 insertions, 12 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);