Here is a half-assed old version of chmod, in the vein of v5 chmod.
It has a man page and informative ed-style error messages, but no
recursion or POSIX-style 'symbolic mode expressions.'  I'll refactor
it to use util/recurse later.  I don't really care about 'symbolic
mode expressions.'

-- 
# Kurt H Maier
/* See LICENSE file for copyright and license details. */
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "util.h"

int
main(int argc, char *argv[])
{
  int retval, filecount, i;
  mode_t mode;
  char *input;
  
  mode = 0;
  filecount = argc-1;
  input = argv[1];
    
  if ( argc < 3 ) {
    eprintf("?\n");
    exit(EXIT_FAILURE);
  }
    
  while ( *input ) {
    if (*input < '0' || *input > '7') {
      eprintf("?\n");
      exit(EXIT_FAILURE);
    } 
    mode = ( mode << 3 ) | ( *input - '0' ) ;
    input++;
  }
  
  retval=0;
  for (i=2; i <= filecount; i++) {
         retval =  chmod( argv[i], mode ); 
	 if (retval != 0) { printf ("? \n");  }
  }
  exit(EXIT_SUCCESS);
 }

Attachment: chmod.1
Description: Binary data

Reply via email to