Hi

Excause my bad english first, english is not my native langueag :-(

I have added one small feature to gnu chmod. Look at the patch, it's very
usabele I thig.

The feature is in two new parametres -D --dirsonly and -F --filesonly when
you want to change mods recursively only to files or only to directoris.
(because of changing +x mode to directories by using chmod -R 755 . makes me
angry, because +x mode will be changed on files too.) Making scripts
find-based makes me dizzy.

The patch is for chmod from fileutils-4.1.5

Bye

        Ondra Holecek from Czech Republic (see world map :-))
64a65,70
> #define ONLY_FILES    1
> #define ONLY_DIRS     2
> 
> static int df_only;
> 
> 
89a96,97
>   {"onlyfiles", no_argument, 0, 'F'},
>   {"onlydirs", no_argument, 0, 'D'},
167a176,196
>   if (!df_only || (S_ISDIR(file_stats.st_mode) && df_only!=ONLY_FILES) 
>              || (S_ISREG(file_stats.st_mode) && df_only!=ONLY_DIRS) )
>   {
>                 
>         fail = chmod (file, newmode);
>         
>         saved_errno = errno;
> 
>         
>         if (verbosity == V_high
>             || (verbosity == V_changes_only
>                 && !fail && mode_changed (file, file_stats.st_mode)))
>           describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));
>         
>         if (fail)
>           {
>             if (force_silent == 0)
>               error (0, saved_errno, _("changing permissions of %s"),
>                      quote (file));
>             errors = 1;
>           }
169,184c198,199
<   fail = chmod (file, newmode);
<   saved_errno = errno;
< 
<   if (verbosity == V_high
<       || (verbosity == V_changes_only
<         && !fail && mode_changed (file, file_stats.st_mode)))
<     describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));
< 
<   if (fail)
<     {
<       if (force_silent == 0)
<       error (0, saved_errno, _("changing permissions of %s"),
<              quote (file));
<       errors = 1;
<     }
< 
---
>   }
>   
256a272,273
>   -F, --onlyfiles         change files only\n\
>   -D, --onlydirs          change dirs only\n\
289c306
<   recurse = force_silent = 0;
---
>   df_only = recurse = force_silent = 0;
295c312
<       c = getopt_long (argc, argv, "RcfvrwxXstugoa,+-=", long_options, NULL);
---
>       c = getopt_long (argc, argv, "RDFcfvrwxXstugoa,+-=", long_options, NULL);
301a319,328
>         break;
>       case 'D':
>         if (df_only)
>           usage(1);
>         df_only = ONLY_DIRS;
>         break;
>       case 'F':
>         if (df_only)
>           usage(1);
>         df_only = ONLY_FILES;

Reply via email to