aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-09-25 12:49:40 -0500
committerRob Landley <rob@landley.net>2019-09-25 12:49:40 -0500
commit0489bdd7da194cc8224910b0d8ba09ba19490815 (patch)
treeea51f21d4f27a9f997c8c2755623d19089778b3d /toys
parent9aaa950d3a0d5518709f84c80b06fd761f992fe8 (diff)
downloadtoybox-0489bdd7da194cc8224910b0d8ba09ba19490815.tar.gz
Use FLAG macros
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/ln.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/toys/posix/ln.c b/toys/posix/ln.c
index 06700dd0..7f635402 100644
--- a/toys/posix/ln.c
+++ b/toys/posix/ln.c
@@ -37,8 +37,7 @@ void ln_main(void)
}
// Is destination a directory?
- if (((toys.optflags&FLAG_n) ? lstat : stat)(dest, &buf)
- || !S_ISDIR(buf.st_mode))
+ if ((FLAG(n) ? lstat : stat)(dest, &buf) || !S_ISDIR(buf.st_mode))
{
if (toys.optc>1) error_exit("'%s' not a directory", dest);
buf.st_mode = 0;
@@ -55,7 +54,7 @@ void ln_main(void)
// a temp version and renaming it over the old one, so we can retain the
// old file in cases we can't replace it (such as hardlink between mounts).
oldnew = new;
- if (toys.optflags & FLAG_f) {
+ if (FLAG(f)) {
new = xmprintf("%s_XXXXXX", new);
rc = mkstemp(new);
if (rc >= 0) {
@@ -64,8 +63,8 @@ void ln_main(void)
}
}
- rc = (toys.optflags & FLAG_s) ? symlink(try, new) : link(try, new);
- if (toys.optflags & FLAG_f) {
+ rc = FLAG(s) ? symlink(try, new) : link(try, new);
+ if (FLAG(f)) {
if (!rc) {
int temp;
@@ -77,11 +76,9 @@ void ln_main(void)
free(new);
new = oldnew;
}
- if (rc)
- perror_msg("cannot create %s link from '%s' to '%s'",
- (toys.optflags & FLAG_s) ? "symbolic" : "hard", try, new);
- else
- if (toys.optflags & FLAG_v) fprintf(stderr, "'%s' -> '%s'\n", new, try);
+ if (rc) perror_msg("cannot create %s link from '%s' to '%s'",
+ FLAG(s) ? "symbolic" : "hard", try, new);
+ else if (FLAG(v)) fprintf(stderr, "'%s' -> '%s'\n", new, try);
if (new != dest) free(new);
}