blob: 7f39048054b30f2e9340d8ae2ffb040d1715d170 [file] [log] [blame]
Eric Andersen9f0fedb2001-04-24 18:07:19 +00001/* vi: set sw=4 ts=4: */
2/*
Eric Andersenbdfd0d72001-10-24 05:00:29 +00003 * Mini chgrp implementation for busybox
Eric Andersen9f0fedb2001-04-24 18:07:19 +00004 *
Eric Andersenc7bda1c2004-03-15 08:29:22 +00005 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Eric Andersen9f0fedb2001-04-24 18:07:19 +00006 *
Bernhard Reutner-Fischerb1629b12006-05-19 19:29:19 +00007 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Eric Andersen9f0fedb2001-04-24 18:07:19 +00008 */
9
Denis Vlasenko02f0c4c2007-03-09 10:08:53 +000010/* BB_AUDIT SUSv3 defects - none? */
Denis Vlasenkoe80e2a32006-10-27 23:28:38 +000011/* BB_AUDIT GNU defects - unsupported long options. */
Manuel Novoa III cad53642003-03-19 09:13:01 +000012/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */
13
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000014#include "libbb.h"
Eric Andersen9f0fedb2001-04-24 18:07:19 +000015
Denis Vlasenko99912ca2007-04-10 15:43:37 +000016/* This is a NOEXEC applet. Be very careful! */
17
18
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000019int chgrp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Eric Andersen9f0fedb2001-04-24 18:07:19 +000020int chgrp_main(int argc, char **argv)
21{
Denis Vlasenkoe80e2a32006-10-27 23:28:38 +000022 /* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */
23 char **p = argv;
24 while (*++p) {
25 if (p[0][0] != '-') {
26 p[0] = xasprintf(":%s", p[0]);
27 break;
Eric Andersen9f0fedb2001-04-24 18:07:19 +000028 }
Denis Vlasenkoe80e2a32006-10-27 23:28:38 +000029 }
30 return chown_main(argc, argv);
Eric Andersen9f0fedb2001-04-24 18:07:19 +000031}