aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/cp.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-08-31 15:02:21 -0500
committerRob Landley <rob@landley.net>2018-08-31 15:14:12 -0500
commit8993496e496cdbc80643b69d049d05bbd7f596b3 (patch)
tree8790f2ada6dfdc0e98265672cac9b8ae07bfce56 /toys/posix/cp.c
parent198b2b48345c175dc184258677fd48043dc1a78b (diff)
downloadtoybox-8993496e496cdbc80643b69d049d05bbd7f596b3.tar.gz
Convert option style.
Diffstat (limited to 'toys/posix/cp.c')
-rw-r--r--toys/posix/cp.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index 216d4592..373ac13e 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -97,12 +97,11 @@ config INSTALL
GLOBALS(
union {
+ // install's options
struct {
- // install's options
- char *group;
- char *user;
- char *mode;
+ char *g, *o, *m;
} i;
+ // cp's options
struct {
char *preserve;
} c;
@@ -469,10 +468,9 @@ static inline int cp_flag_v(void) { return FLAG_v; };
static int install_node(struct dirtree *try)
{
- try->st.st_mode = (TT.i.mode)
- ? string_to_mode(TT.i.mode, try->st.st_mode) : 0755;
- if (TT.i.group) try->st.st_gid = TT.gid;
- if (TT.i.user) try->st.st_uid = TT.uid;
+ try->st.st_mode = TT.i.m ? string_to_mode(TT.i.m, try->st.st_mode) : 0755;
+ if (TT.i.g) try->st.st_gid = TT.gid;
+ if (TT.i.o) try->st.st_uid = TT.uid;
// Always returns 0 because no -r
cp_node(try);
@@ -511,8 +509,8 @@ void install_main(void)
if (flags & FLAG_v) toys.optflags |= cp_flag_v();
if (flags & (FLAG_p|FLAG_o|FLAG_g)) toys.optflags |= cp_flag_p();
- if (TT.i.user) TT.uid = xgetuid(TT.i.user);
- if (TT.i.group) TT.gid = xgetgid(TT.i.group);
+ if (TT.i.o) TT.uid = xgetuid(TT.i.o);
+ if (TT.i.g) TT.gid = xgetgid(TT.i.g);
TT.callback = install_node;
cp_main();