diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
commit | cad5364599eb5062d59e0c397ed638ddd61a8d5d (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /coreutils/yes.c | |
parent | e01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff) | |
download | busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2 busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip |
Major coreutils update.
Diffstat (limited to 'coreutils/yes.c')
-rw-r--r-- | coreutils/yes.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/coreutils/yes.c b/coreutils/yes.c index 7d9596d0b..74f7571cf 100644 --- a/coreutils/yes.c +++ b/coreutils/yes.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * Mini yes implementation for busybox | 3 | * yes implementation for busybox |
4 | * | 4 | * |
5 | * Copyright (C) 2000 Edward Betts <edward@debian.org>. | 5 | * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
@@ -20,7 +20,12 @@ | |||
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | 22 | ||
23 | /* getopt not needed */ | 23 | /* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ |
24 | |||
25 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) | ||
26 | * | ||
27 | * Size reductions and removed redundant applet name prefix from error messages. | ||
28 | */ | ||
24 | 29 | ||
25 | #include <stdio.h> | 30 | #include <stdio.h> |
26 | #include <stdlib.h> | 31 | #include <stdlib.h> |
@@ -28,26 +33,24 @@ | |||
28 | 33 | ||
29 | extern int yes_main(int argc, char **argv) | 34 | extern int yes_main(int argc, char **argv) |
30 | { | 35 | { |
31 | int i; | 36 | static const char fmt_str[] = " %s"; |
32 | 37 | const char *fmt; | |
33 | if (argc >= 2 && *argv[1] == '-') | 38 | char **first_arg; |
34 | show_usage(); | ||
35 | 39 | ||
36 | if (argc == 1) { | 40 | *argv = "y"; |
37 | while (1) | 41 | if (argc != 1) { |
38 | if (puts("y") == EOF) { | 42 | ++argv; |
39 | perror("yes"); | ||
40 | return EXIT_FAILURE; | ||
41 | } | ||
42 | } | 43 | } |
43 | 44 | ||
44 | while (1) | 45 | first_arg = argv; |
45 | for (i = 1; i < argc; i++) | 46 | do { |
46 | if (fputs(argv[i], stdout) == EOF | 47 | fmt = fmt_str + 1; |
47 | || putchar(i == argc - 1 ? '\n' : ' ') == EOF) { | 48 | do { |
48 | perror("yes"); | 49 | bb_printf(fmt, *argv); |
49 | return EXIT_FAILURE; | 50 | fmt = fmt_str; |
50 | } | 51 | } while (*++argv); |
52 | argv = first_arg; | ||
53 | } while (putchar('\n') != EOF); | ||
51 | 54 | ||
52 | return EXIT_SUCCESS; | 55 | bb_perror_nomsg_and_die(); |
53 | } | 56 | } |