| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commits 8e6991733 and b2901ce8e fixed problems with the 'read'
shell built-in when the '-t' option was used. However, they
result in a performance penalty. This pipeline:
seq -w 0 999999 | while read line; do :; done
takes 10 times longer than prior to the changes.
If no timeout is specified don't call poll(2).
Costs 16 bytes in a 32-bit build; 0 in 64-bit.
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
unset_local_var - 112 +112
findvar 31 35 +4
set_vars_and_save_old 144 141 -3
helper_export_local 235 230 -5
set_local_var 425 416 -9
handle_changed_special_names 38 27 -11
builtin_unset 154 141 -13
builtin_getopts 404 391 -13
get_local_var_value 281 260 -21
get_ptr_to_local_var 71 45 -26
unset_local_var_len 139 - -139
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/8 up/down: 116/-240) Total: -124 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Consider this test case:
{ echo -n te; sleep 3; echo st; } | (read -t 1 x; echo "$x")
- bash echoes "te" after 1 second.
- Upstream BusyBox echoes an empty "$x" after 1 second.
- busybox-w32 echoes an empty "$x" after 3 seconds.
The delayed echo in busybox-w32 arises because the 'read' shell
built-in omits the code to poll for input.
Rearrange the code so that polling takes place. This doesn't address
the difference between BusyBox and bash.
Costs 48-64 bytes.
|
| |
| |
| |
| |
| |
| |
| | |
The 'read' shell built-in echoed console input to stdout. Echo
directly to the console instead.
Costs 124-136 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
No further problems with CRLF handling have been reported. Remove
the configuration option that allowed some recent changes to be
turned off.
Also, prevent some WIN32 code from being included in the POSIX
build. The faulty code is from commit 64c8f5f3d (ash: add support
for INT trap).
These changes don't alter the default WIN32 build.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- Disable ENABLE_PROCESSED_INPUT in raw mode. Otherwise ^C isn't
immediately detected during shell command line editing with
virtual terminal input enabled.
- Switch read_key()/unix_readkey() to windows_read_key()/read_key().
This allows the shell `read` builtin to use windows_read_key().
Without this change `read` fails when virtual terminal input is
enabled.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 0eda390d6 (ash: improve handling of 'read -t 0') added code
to work around the limitations of our poll(2) implementation.
Now that poll(2) has been improved the workaround is unnecessary.
Saves 64 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit deae0c7bf3 (Skip carriage return in read builtin command)
caused all CRs to be removed from input to the read builtin.
Only remove CRs that are part of a CRLF pair.
Adds 64-80 bytes.
(GitHub issue #285)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit e371e46fa0 (shell: add \r to IFS) added '\r' to the IFS
variable so field splitting would remove carriage returns.
Rather than change IFS, remove CRs preceding LFs in regions
being scanned for field splitting before IFS is applied. This
prevents free-standing CRs from being removed.
Costs 112-120 bytes.
(GitHub issue #285)
|
|\|
| |
| |
| |
| |
| |
| |
| | |
Fix conflicts in reset and ash.
Redefine the new safe_read_key() as a reference to read_key().
Disable SHA256_HWACCEL.
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| | |
On Sat, Feb 9, 2019 Cristian Ionescu-Idbohrn wrote:
> In my case (at work), I have to watch and prevent people from doing
> unportable things. For me, that's a burden.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The original commit 3bef5d89b0 introduced an additional check
for an unset `opt_d` before doing word splitting. I'm unsure
why it's there in the first place, but the commit message also
describes a different behaviour than what -d actually does in
bash, while the code mostly does the right thing.
`opt_d` sets the line delimiter for read to stop reading and
should not affect word splitting.
Testcase:
$ echo qwe rty | { read -d Z a b; echo a:$a b:$b; }
a:qwe b:rty
function old new delta
shell_builtin_read 1314 1304 -10
Signed-off-by: Eicke Herbertz <wolletd@posteo.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| | |
text data bss dec hex filename
1021988 559 5052 1027599 fae0f busybox_old
1021236 559 5052 1026847 fab1f busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
With bash's read builtin it is possible to read from a file (e.g.
device-tree) until the first '\0' character:
IFS= read -r -d '' VARIABLE < file
In busybox ash the -d extension is also implemented, but checking the
read character for '\0' has to be performed after comparing with the
delimiter.
Signed-off-by: Christian Eggers <ceggers@arri.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| | |
When the '-n' option of the 'read' builtin is used we need to account
for backspaces: increase 'nchars' when backspace removes a character
from the buffer.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Consider this script:
while read -r; do echo $REPLY; done
echo hello
There are currently two problems with this when the read is interrupted
by ctrl-C:
- The error return code is 0 when it should be 130;
- The echo command is executed.
Fix these issues by propagating the control event to the process that
would have caught it if the read builtin hadn't grabbed keyboard input.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The read builtin didn't detect EOF so it wasn't possible to cleanly
terminate a loop like:
while read -r; do echo $REPLY; done
Consider how Linux handles EOF (represented as ^D, though this isn't
echoed):
$ awk '{print}' | xxd
abc^D123
^D
00000000: 6162 6331 3233 0a abc123.
Contrast with busybox-w32 on Windows (where the ^Z is echoed):
$ awk '{print}' | xxd
abc^Z123
^Z
00000000: 6162 631a 3132 330a abc.123.
In both cases EOF is only detected at the start of a line. On Linux
EOF within a line is dropped; on Windows it's output as a literal ctrl-Z.
Implement similar behaviour for the read builtin.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Previously the 'read' builtin had no special treatment for backspace
characters entered in interactive mode: they were simply added to
the string being read.
Change this so that backspace deletes the previous character from
the buffer and updates the display to match. It still doesn't
handle tabs in the input or lines that are larger than the console
width.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| | |
text data bss dec hex filename
1001949 551 5612 1008112 f61f0 busybox_old
1001906 551 5612 1008069 f61c5 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Back in 2007, commit 0c97c9d43707 ("'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>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
helper_export_local 215 253 +38
leave_var_nest_level 107 127 +20
run_pipe 1840 1857 +17
handle_changed_special_names 101 105 +4
shell_builtin_read 1399 1398 -1
done_word 767 766 -1
parse_stream 2249 2245 -4
set_local_var 437 430 -7
is_well_formed_var_name 66 - -66
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 4/4 up/down: 79/-79) Total: 0 bytes
text data bss dec hex filename
952376 485 7296 960157 ea69d busybox_old
952400 485 7296 960181 ea6b5 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
limits_tbl 104 120 +16
ulimit_opt_string 44 50 +6
limit_chars 14 16 +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 24/0) Total: 24 bytes
text data bss dec hex filename
981996 485 7296 989777 f1a51 busybox_old
982065 485 7296 989846 f1a96 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
shell_builtin_ulimit 486 651 +165
limit_chars - 14 +14
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 179/0) Total: 179 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Instead of always returning that no input is available:
- for a disk file return 'available';
- for the console return 'not available';
- for anything else (e.g. pipe) return whatever poll says.
This fixes the test ash-read/read_t0.tests.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The euro currency symbol was added to some OEM code pages. See:
https://www.aivosto.com/articles/charsets-codepages-dos.html
Add a configuration option (enabled by default) to support this.
When enabled:
- The read_key() function requests wide character key events. This
allows the euro symbol to be entered regardless of the console OEM
code page, though it needs to be available in the ANSI code page.
- Conversions between OEM and ANSI code pages in winansi.c are
modified to work around a bug in the Microsoft routines.
- If the OEM code page is 850 when BusyBox starts it's changed to
858. This is the only currently supported OEM code page.
Also, the shell read builtin is modified to use read_key() whenever
input is being taken from the console.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
getoptscmd 587 584 -3
readcmd 240 224 -16
shell_builtin_read 1426 1399 -27
builtin_read 210 182 -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-74) Total: -74 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
$ echo "X:Y:" | (IFS=": " read x y; echo "|$x|$y|")
|X|Y|
$ echo "X:Y : " | (IFS=": " read x y; echo "|$x|$y|")
|X|Y|
function old new delta
shell_builtin_read 1320 1426 +106
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| | |
Raw input should also be used when the -s flag is present.
Related to GitHub issue #112.
|
|\| |
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Use read_key to emulate raw input when reading from the console.
Limit this to cases where raw input is necessary:
- a maximum number of characters is to be read (-n)
- a timeout has been specified (-t)
- a non-standard delimiter is in use (-d)
This should fix GitHub issue #112 (and other things too!).
Also, omit sections of code that serve no purpose on WIN32.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
NOEXEC'ed applets which use getopt() need this.
function old new delta
builtin_getopts 403 413 +10
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|\| |
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
shell_builtin_read 1334 1320 -14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The POSIX standard only requires the read builtin to handle -r:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html
However, Bash introduced the option -d <DELIM> to override IFS for
just one invocation, and it is quite useful.
It is also super easy to implement in BusyBox' ash, so let's do that.
The motivation: This option is used by Git's test suite.
function old new delta
.rodata 163505 163587 +82
shell_builtin_read 1244 1289 +45
readcmd 233 259 +26
builtin_read 258 263 +5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 158/0) Total: 158 bytes
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|