Compile with Werror flag. Found bug in xargs
This commit is contained in:
parent
abdb5a8f03
commit
d5fddf4dcf
4
TODO
4
TODO
|
@ -1,7 +1,6 @@
|
||||||
With "micro-" prefix
|
With "micro-" prefix
|
||||||
|
|
||||||
*Todo:
|
*Todo:
|
||||||
*echo
|
|
||||||
tail
|
tail
|
||||||
expr
|
expr
|
||||||
uniq
|
uniq
|
||||||
|
@ -54,7 +53,7 @@ Modutils (linux only):
|
||||||
Findutils:
|
Findutils:
|
||||||
grep
|
grep
|
||||||
find
|
find
|
||||||
*xargs (-r flag)
|
|
||||||
Shell:
|
Shell:
|
||||||
rc - run command (1 2 3 ~ | <> <<>> & * " parsing) (sig handler)
|
rc - run command (1 2 3 ~ | <> <<>> & * " parsing) (sig handler)
|
||||||
|
|
||||||
|
@ -63,3 +62,4 @@ Init:
|
||||||
|
|
||||||
BUGS:
|
BUGS:
|
||||||
ls (unicode strlen, -l flag col)
|
ls (unicode strlen, -l flag col)
|
||||||
|
xargs (getopt with glibc)
|
||||||
|
|
2
config.h
2
config.h
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
/* Max args (xargs) */
|
/* Max args (xargs) */
|
||||||
#define NARGS 1024
|
#define NARGS 1024
|
||||||
|
|
||||||
|
/* Arg size (xargs) */
|
||||||
#define ARG_SIZE 1024
|
#define ARG_SIZE 1024
|
||||||
|
|
||||||
/* Default cmd (xargs) */
|
/* Default cmd (xargs) */
|
||||||
|
|
|
@ -19,7 +19,10 @@ int cat(const char *path) {
|
||||||
char buf[BUF_SIZE + 1];
|
char buf[BUF_SIZE + 1];
|
||||||
off_t len = 0;
|
off_t len = 0;
|
||||||
while ((len = read(fd, buf, sizeof(buf))) > 0)
|
while ((len = read(fd, buf, sizeof(buf))) > 0)
|
||||||
write(STDOUT_FILENO, buf, len);
|
if (write(STDOUT_FILENO, buf, len) != len) {
|
||||||
|
fprintf(stderr, "cat: %s\n", strerror(errno));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(path, "-"))
|
if (strcmp(path, "-"))
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
@ -15,7 +15,7 @@ int main(const int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
chdir("/");
|
(void)chdir("/");
|
||||||
if (execvp(argv[2], argv + 2) < 0) {
|
if (execvp(argv[2], argv + 2) < 0) {
|
||||||
fprintf(stderr, "chroot: %s\n", strerror(errno));
|
fprintf(stderr, "chroot: %s\n", strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -26,7 +26,7 @@ int shred(int rand_fd, int fd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int n = 0; n < n_loops; n++) {
|
for (unsigned int n = 0; n < n_loops; n++) {
|
||||||
read(rand_fd, buf, size);
|
(void)read(rand_fd, buf, size);
|
||||||
fsync(fd);
|
fsync(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,10 @@ int main(int argc, char **argv) {
|
||||||
char buf[BUF_SIZE + 1];
|
char buf[BUF_SIZE + 1];
|
||||||
off_t bytes = 0;
|
off_t bytes = 0;
|
||||||
while ((bytes = read(STDIN_FILENO, buf, sizeof(buf)))) {
|
while ((bytes = read(STDIN_FILENO, buf, sizeof(buf)))) {
|
||||||
write(STDOUT_FILENO, buf, bytes);
|
(void)write(STDOUT_FILENO, buf, bytes);
|
||||||
|
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
write(fd, buf, bytes);
|
(void)write(fd, buf, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
|
|
|
@ -57,7 +57,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
|
||||||
/* Print */
|
/* Print */
|
||||||
write(STDOUT_FILENO, buf, n);
|
(void)write(STDOUT_FILENO, buf, n);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
Loading…
Reference in New Issue