Commit Graph

62 Commits

Author SHA1 Message Date
Denys Vlasenko
0e2cb6d1e2 echo: add FIXME comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-29 07:26:23 +01:00
Denys Vlasenko
e2b9215868 *: --help tweaks
function                                             old     new   delta
packed_usage                                       33589   33552     -37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-14 20:47:20 +02:00
Denys Vlasenko
7c813fbabf echo: fix !ENABLE_FEATURE_FANCY_ECHO build
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-14 18:55:30 +02:00
Natanael Copa
e880c9c100 echo: do not assume that free() leaves errno unmodified
musl libc's mallocng free() may modify errno if kernel does not support
MADV_FREE which causes echo to echo with error when it shouldn't.

Future versions of POSIX[1] will require that free() leaves errno
unmodified but til then, do not rely free() implementation.

Should fix downstream issues:
https://github.com/alpinelinux/docker-alpine/issues/134
https://gitlab.alpinelinux.org/alpine/aports/-/issues/12311

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-23 12:59:29 +01:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().

This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.

Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.

This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.

The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):

Arm:     -92 bytes
MIPS:    -52 bytes
PPC:   -1836 bytes
x86_64: -938 bytes

Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.

Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
b86b39bfda config: more tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28 17:52:43 +01:00
Denys Vlasenko
95f7953f2c do not use `a' quoting style in comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-02 14:26:33 +02:00
Denys Vlasenko
72089cf6b4 config: deindent all help texts
Those two spaces after tab have no effect, and always a nuisance when editing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21 09:50:55 +02:00
Denys Vlasenko
265062d59d shells: make hush test optional, rename ASH_BUILTIN_foo -> ASH_foo
This makes hash and ash more symmetrical wrt config menu and config
options.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 15:13:30 +01:00
Denys Vlasenko
f560422fa0 Big cleanup in config help and description
Redundant help texts (one which only repeats the description)
are deleted.

Descriptions and help texts are trimmed.

Some config options are moved, even across menus.

No config option _names_ are changed.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10 14:58:54 +01:00
Denys Vlasenko
af3f420116 Convert all coreutils/* applets to "new style" applet definitions
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-23 14:46:56 +01:00
Mike Frysinger
670c3f7822 echo: make escape sequences depend on fancy mode
Currently when you disable fancy echo, escape sequences are hardcoded
enabled (e.g. as if you used `echo -e` all the time).  The opposite
behavior is more desirable (always disable -e support) because:
* This seems to contradict the spirit of the kconfig help text (where
  it says enable support for -n/-e flags), although you could say that
  we aren't supporting the -e flag directly as `echo -e` will show the
  -e flag.
* POSIX makes escape sequences optional, and even says they are there
  only on XSI-conformant systems.
* It saves space (~100 bytes on x86_64).
* It makes things faster!
* It makes it behave more like bash where you need an explicit -e flag
  in order for escape sequences to be interpreted.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-31 03:47:49 +02:00
Denys Vlasenko
66426760be *: remove "Options:" string from help texts
function                                             old     new   delta
packed_usage                                       28706   28623     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05 03:58:28 +02:00
Pere Orga
34425389e0 move help text from include/usage.src.h to coreutils/*.c
Signed-off-by: Pere Orga <gotrunks@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-03-31 14:43:25 +02:00
Denys Vlasenko
4fdb67cc65 echo: fix SEGV when run with no args
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-15 18:35:54 +01:00
Denys Vlasenko
b9348440b0 echo: fix ENOSPC detection and some iffy code in \NNN handling
function                                             old     new   delta
echo_main                                            330     302     -28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-14 15:42:18 +01:00
Denys Vlasenko
8ee2adab21 echo: do not retry on write errors
function                                             old     new   delta
echo_main                                            297     336     +39
stpcpy                                                 -      22     +22
run_pipe                                            1561    1566      +5
pseudo_exec_argv                                     187     192      +5
hush_exit                                             75      80      +5
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 4/0 up/down: 98/0)               Total: 76 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-02-07 02:03:51 +01:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00
Denys Vlasenko
8131eea3dc *: introduce and use ffulsh_all()
function                                             old     new   delta
buffer_fill_and_print                                179     196     +17
fflush_all                                             -       9      +9
spawn                                                 87      92      +5
rtcwake_main                                         455     453      -2
...
alarm_intr                                            93      84      -9
readcmd                                             1072    1062     -10
bb_ask                                               345     333     -12
more_main                                            845     832     -13
flush_stdout_stderr                                   42      23     -19
xfflush_stdout                                        27       -     -27
flush_stderr                                          30       -     -30
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/50 up/down: 31/-397)         Total: -366 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-02 14:19:51 +01:00
Denis Vlasenko
6a0ad25061 ash: dont allow e.g. exec <&10 to attach to stript's fd!
function                                             old     new   delta
is_hidden_fd                                           -      61     +61
redirect                                            1135    1164     +29
popstring                                            134     140      +6
printf_main                                          635     637      +2
evalvar                                             1374    1376      +2
echo_main                                            294     296      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/0 up/down: 102/0)             Total: 102 bytes
2008-07-25 13:34:05 +00:00
Denis Vlasenko
a60f84ebf0 *: rename ATTRIBUTE_XXX to just XXX. 2008-07-05 09:18:54 +00:00
Denis Vlasenko
dcbd350ccf echo: fix echo -e -n "msg\n\0"
(by "Pinedo, David" <david.pinedo AT hp.com>)
2008-04-30 00:39:22 +00:00
Denis Vlasenko
468aea2d88 shells: do not frocibly enable test, echo and kill _applets_,
just build relevant source and use xxx_main functions.
build system: add a special case when we have exactly one applet enabled
(makes "true", "false", "basename" REALLY tiny).
getopt32: do not use stdio.

function                                             old     new   delta
getopt32                                            1385    1412     +27
make_device                                         1187    1200     +13
basename_main                                        120     127      +7
tcpudpsvd_main                                      1922    1926      +4
testcmd                                                5       -      -5
echocmd                                                5       -      -5
fuser_main                                          1243    1231     -12
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 4/1 up/down: 51/-22)             Total: 29 bytes
2008-04-01 14:47:57 +00:00
Denis Vlasenko
68404f13d4 *: add -Wunused-parameter; fix resulting breakage
function                                             old     new   delta
procps_scan                                         1265    1298     +33
aliascmd                                             278     283      +5
parse_file_cmd                                       116     120      +4
dname_enc                                            373     377      +4
setcmd                                                90      93      +3
execcmd                                               57      60      +3
count_lines                                           72      74      +2
process_command_subs                                 340     339      -1
test_main                                            409     407      -2
mknod_main                                           179     177      -2
handle_incoming_and_exit                            2653    2651      -2
argstr                                              1312    1310      -2
shiftcmd                                             131     128      -3
exitcmd                                               46      43      -3
dotcmd                                               297     294      -3
breakcmd                                              86      83      -3
evalpipe                                             353     349      -4
evalcommand                                         1180    1176      -4
evalcmd                                              109     105      -4
send_tree                                            374     369      -5
mkfifo_main                                           82      77      -5
evalsubshell                                         152     147      -5
typecmd                                               75      69      -6
letcmd                                                61      55      -6
add_cmd                                             1190    1183      -7
main                                                 891     883      -8
ash_main                                            1415    1407      -8
parse_stream                                        1377    1367     -10
alloc_procps_scan                                     55       -     -55
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 7/21 up/down: 54/-148)          Total: -94 bytes
   text    data     bss     dec     hex filename
 797195     658    7428  805281   c49a1 busybox_old
 797101     658    7428  805187   c4943 busybox_unstripped
2008-03-17 09:00:54 +00:00
Denis Vlasenko
f7be20e70c nameif: extended matching (Nico Erfurth <masta@perlgolf.de>)
*: whitespace fixes

function                                             old     new   delta
prepend_new_eth_table                                  -     304    +304
nameif_main                                          620     684     +64
cc_macaddr                                            51       -     -51
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/0 up/down: 368/-51)           Total: 317 bytes
2007-12-24 14:09:19 +00:00
Denis Vlasenko
fe5e23bf75 remove echo_main -> bb_echo indirection 2007-11-24 02:23:51 +00:00
Denis Vlasenko
7d75a96b15 ash: fix bug where redirection of closed fd was leaving it open afterwards.
redirect                                             983    1024     +41
bb_echo                                              276     301     +25
popredir                                             118     132     +14
evalcommand                                         1163    1176     +13
bbunpack                                             358     366      +8
echocmd                                               13       5      -8
echo_main                                             13       5      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/2 up/down: 101/-16)            Total: 85 bytes
   text    data     bss     dec     hex filename
 774999     962    9236  785197   bfb2d busybox_old
 775084     962    9236  785282   bfb82 busybox_unstripped
2007-11-22 08:16:57 +00:00
Denis Vlasenko
9b49a5ed85 add -fvisibility=hidden to CC flags, mark XXX_main functions
EXTERNALLY_VISIBLE. 5% size reduction of libbusybox.so
2007-10-11 10:05:36 +00:00
Denis Vlasenko
4daad9004d introduce bb_putchar(). saves ~1800 on uclibc (less on glibc). 2007-09-27 10:20:47 +00:00
Denis Vlasenko
bb98db2ed2 echo: fix yet another buglet in non-fancy echo 2007-06-19 23:04:17 +00:00
Bernhard Reutner-Fischer
def8260219 - fix invocation without any argument 2007-06-08 12:52:17 +00:00
Denis Vlasenko
c084d2f205 echo: fix non-fancy echo 2007-06-06 07:50:51 +00:00
Denis Vlasenko
b6adbf1be2 usage.c: remove reference to busybox.h
*: s/include "busybox.h"/include "libbb.h"
2007-05-26 19:00:18 +00:00
Denis Vlasenko
335b63d8d1 make a few struct bb_applet members conditional
rename sllep_and_die -> xfunc_die
make fflush_stdout_and_exit NOFORK-safe
fix some buglets found by randomconfig
2007-04-10 21:38:30 +00:00
Denis Vlasenko
a9d7d24e1f echo: fix regression ("echo" with no arguments didn't print newline.
echo: use fputs if no options are given. Code growth ~15 bytes.

Old:
# time ./busybox find $bigdir -exec echo {} \; >/dev/null
real    0m2.038s
user    0m0.761s
sys     0m0.953s

New:
# time ./busybox find $bigdir -exec echo {} \; >/dev/null
real    0m1.781s
user    0m0.781s
sys     0m0.939s

For comparison: without NOFORK:
# time find $bigdir -exec echo {} \; >/dev/null
real    1m51.129s
user    0m38.442s
sys     1m3.350s
2007-04-10 16:34:00 +00:00
Denis Vlasenko
7e754f12d3 Implement first instance of NOFORK applet - echo
find: use NOFORK/NOEXEC; small -exec buglet also eliminated
vfork_daemon_rexec: honor PREFER_APPLETS
echo: small size improvements

find -exec echo {} \; with PREFER_APPLETS=y runs 4 times faster
2007-04-09 13:04:50 +00:00
Denis Vlasenko
06af216528 suppress warnings about easch <applet>_main() having
no preceding prototype
2007-02-03 17:28:39 +00:00
Denis Vlasenko
bf66fbc8e2 introduce LONE_CHAR (optimized strcmp with one-char string) 2006-12-21 13:23:14 +00:00
Denis Vlasenko
f0ed376eda remove bb_printf and the like 2006-10-26 23:21:47 +00:00
"Robert P. J. Day"
68229837ff Remove all usage of the "register" storage class specifier. 2006-07-01 13:08:46 +00:00
Paul Fox
6ab037872f made "test" an ash built-in.
moved the contents of libbb/bb_echo.c back into coreutils/echo.c,
which is a more reasonable place for them than libbb.  this
forces anyone who wants echo and test to be builtin to ash to
also have them available as applets.  their cost is very small,
and the number of people who wouldn't want them as applets is
also very small.

added warning about shell builtins vs. CONFIG_FEATURE_SH_STANDALONE_SHELL,
which conflicts with their use.

thanks to nathanael copa for debugging help.

some string size optimization in test.c may have been lost with
this commit, but this is a good new baseline.
2006-06-08 21:37:26 +00:00
Rob Landley
dfba741457 Robert P. Day removed 8 gazillion occurrences of "extern" on function
definitions.  (That should only be on prototypes.)
2006-03-06 20:47:33 +00:00
Paul Fox
0b62158475 implemented a builtin echo command in ash. moved the guts of the
echo applet into libbb, and now call bb_echo() from both echo.c
and ash.c
2005-08-09 19:38:05 +00:00
Eric Andersen
aff114c33d Larry Doolittle writes:
This is a bulk spelling fix patch against busybox-1.00-pre10.
If anyone gets a corrupted copy (and cares), let me know and
I will make alternate arrangements.

Erik - please apply.

Authors - please check that I didn't corrupt any meaning.

Package importers - see if any of these changes should be
passed to the upstream authors.

I glossed over lots of sloppy capitalizations, missing apostrophes,
mixed American/British spellings, and German-style compound words.

What is "pretect redefined for test" in cmdedit.c?

Good luck on the 1.00 release!

      - Larry
2004-04-14 17:51:38 +00:00
Eric Andersen
c7bda1ce65 Remove trailing whitespace. Update copyright to include 2004. 2004-03-15 08:29:22 +00:00
Manuel Novoa III
cad5364599 Major coreutils update. 2003-03-19 09:13:01 +00:00
Eric Andersen
e5dfced23a Apply Vladimir's latest cleanup patch.
-Erik
2001-04-09 22:48:12 +00:00
Eric Andersen
1ca20a7747 A nice patch from Larry Doolittle that adds -Wshadow and
cleans up most of the now-revealed problems.
2001-03-21 07:34:27 +00:00
Eric Andersen
cbe31dace5 It turns out that DODMALLOC was broken when I reorganized busybox.h
header file usage before the 0.49 release.  To fix it, I had to move
the '#include "busybox.h"' to the end of the list of #include files.
 -Erik
2001-02-20 06:14:08 +00:00
Eric Andersen
ed3ef50c23 Fix header file usage -- there were many unnecessary header files included in
busybox.h which slowed compiles.  I left only what was needed and then fixed up
all the apps to include their own header files.  I also fixed naming for pwd.h
and grp.h functions.  Tested to compile and run with libc5, glibc, and uClibc.
 -Erik
2001-01-27 08:24:39 +00:00