.
authorJim Meyering <jim@meyering.net>
Wed, 5 Oct 1994 00:43:46 +0000 (00:43 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 5 Oct 1994 00:43:46 +0000 (00:43 +0000)
src/chmod.c
src/chown.c

index 6a0ebb7..17495cb 100644 (file)
 #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);
index b6e2031..3eac74a 100644 (file)
@@ -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);
 }