void chattr_main(void) { char **argv = toys.optargs; memset(&chattr, 0, sizeof(struct _chattr)); parse_cmdline_arg(&argv); if (!*argv) help_exit("no file"); if (chattr.set && (chattr.add || chattr.rm)) error_exit("no '=' with '-' or '+'"); if (chattr.rm & chattr.add) error_exit("set/unset same flag"); if (!(chattr.add || chattr.rm || chattr.set || chattr.vflag)) error_exit("need '-v', '=', '-' or '+'"); for (; *argv; argv++) dirtree_read(*argv, update_attr); toys.exitval = 0; //always set success at this point. }
void chattr_main(void) { char **argv = toys.optargs; memset(&chattr, 0, sizeof(struct _chattr)); parse_cmdline_arg(&argv); if (!*argv) chattr_help(); if (chattr.set && (chattr.add || chattr.rm)) error_exit("'=' is incompatible with '-' and '+'"); if (chattr.rm & chattr.add) error_exit("Can't set and unset same flag."); if (!(chattr.add || chattr.rm || chattr.set || chattr.vflag)) error_exit(("Must use '-v', '=', '-' or '+'")); for (; *argv; argv++) dirtree_read(*argv, update_attr); toys.exitval = 0; //always set success at this point. }