diff options
author | Ethan Sommer <e5ten.arch@gmail.com> | 2020-04-14 20:05:56 -0400 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-04-14 23:11:57 -0500 |
commit | f457a38ebd67c554f38e4dbfbd42a8e762759066 (patch) | |
tree | 09495ac2657ea0f51a514a4cd261c0af027f1346 /toys/other | |
parent | 97af31fd7a9e5b35b98d65e5d64ef00b5ff7d0b5 (diff) | |
download | toybox-f457a38ebd67c554f38e4dbfbd42a8e762759066.tar.gz |
shred: fix -z flag check, switch to FLAG() macros.
Diffstat (limited to 'toys/other')
-rw-r--r-- | toys/other/shred.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/toys/other/shred.c b/toys/other/shred.c index 1bac75c5..3911e249 100644 --- a/toys/other/shred.c +++ b/toys/other/shred.c @@ -37,7 +37,7 @@ void shred_main(void) { char **try; - if (!(toys.optflags & FLAG_n)) TT.n++; + if (!FLAG(n)) TT.n++; // We don't use loopfiles() here because "-" isn't stdin, and want to // respond to files we can't open via chmod. @@ -47,7 +47,7 @@ void shred_main(void) int fd = open(*try, O_RDWR), iter = 0, throw; // do -f chmod if necessary - if (fd == -1 && (toys.optflags & FLAG_f)) { + if (fd == -1 && FLAG(f)) { chmod(*try, 0600); fd = open(*try, O_RDWR); } @@ -70,7 +70,7 @@ void shred_main(void) if (pos >= len) { pos = -1; - if (++iter == TT.n && (toys.optargs && FLAG_z)) { + if (++iter == TT.n && FLAG(z)) { memset(toybuf, 0, sizeof(toybuf)); continue; } @@ -88,14 +88,12 @@ void shred_main(void) // Determine length, read random data if not zeroing, write. throw = sizeof(toybuf); - if (toys.optflags & FLAG_x) - if (len-pos < throw) throw = len-pos; + if (FLAG(x) && len-pos < throw) throw = len-pos; if (iter != TT.n) xgetrandom(toybuf, throw, 0); if (throw != writeall(fd, toybuf, throw)) perror_msg_raw(*try); pos += throw; } - if (toys.optflags & FLAG_u) - if (unlink(*try)) perror_msg("unlink '%s'", *try); + if (FLAG(u) && unlink(*try)) perror_msg("unlink '%s'", *try); } } |