| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allowing virtual terminal input mode to be set if available proved
to be unhelpful: cmd.exe doesn't understand such newfangled stuff
(though PowerShell does).
The allowed values of BB_TERMINAL_MODE are changed to:
0 Force console mode.
1 Force virtual terminal mode for output.
2 Force virtual terminal mode for input.
3 Force virtual terminal mode for input and output.
4 Support virtual terminal input if enabled. Don't alter mode.
5 Support virtual terminal input if enabled. Set virtual terminal
mode for output, if possible.
The default is 5.
|
|
|
|
|
|
|
|
|
|
|
| |
- 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Alter certain applets to support virtual terminal input, if enabled.
In many places this is achieved by building previously excluded
upstream terminal-handling code. The busybox-w32 implementation
of termios(3) functions does nothing if virtual terminal input is
disabled, so it can be invoked regardless.
Some applet-specific terminal-handling code is also required.
This affects less, more, vi and command line editing in the shell.
(The `more` applet isn't enabled in the default configuration.)
This series of patches adds about 1.7KB to the binaries.
|
|
|
|
|
|
|
| |
Until now busybox-w32 has used a native Windows implementation
of read_key(). Build the upstream Unix implementation and use
it instead of the native version when virtual terminal input
mode is enabled.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Modify `struct termios` to support Windows virtual terminals.
Native console mode flags replace the Unix `c_?flag` structure
members. Remove unsupported flags from termios.h.
Add implementations of tcgetattr(3)/tcsetattr(3) to get/set console
flags when virtual terminal input mode is enabled.
Add support for emulating raw mode to get_termios_and_make_raw().
This (and related functions) are exposed but not yet used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add the environment variable BB_TERMINAL_MODE as a more general way
of controlling console/terminal mode setting. The default remains
unchanged: use virtual terminal mode for output if possible but
fall back to the console API with emulated ANSI escape sequences.
Currently valid settings are:
0 Force use of console mode
1 Force use of virtual terminal mode for output
5 Prefer virtual terminal mode for output, fall back to console
Other values won't do anything useful until code elsewhere has been
updated.
BB_SKIP_ANSI_EMULATION remains available for backwards compatibility.
If both variables are set BB_TERMINAL_MODE takes precedence.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Upstream started using poll(2) rather than select(2) in `nc` some
time ago, in commit 5b3b468ec (nc: use poll() instead of select()).
Now that poll(2) in busybox-w32 has been updated to work with `nc`
switch to using the same code as upstream.
As a result of this change nothing in busybox-w32 now uses the
select(2) implementation. This reduces the size of the binaries
by about 3.4KB.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Upstream commit 5b3b468ec (nc: use poll() instead of select())
changed `nc` to use poll(2) instead of select(2), obviously.
In busybox-w32 select(2) had already been hacked to support `nc`.
To avoid hacking poll(2) too the upstream change was reverted
(c2002eae3). Later `nc` was altered to include the code for both
poll and select (3c85cc0c4).
Make the changes necessary for poll(2) to work with `nc` on Windows.
These are all in the function windows_compute_revents().
Treat a character file that isn't a console as a normal file.
Without this `nc 127.0.0.1 1234 </dev/null` doesn't work.
Return 0 instead of POLLHUP if GetNumberOfConsoleInputEvents()
indicates no events are available. Without this communication
between two instances of `nc` which are both using keyboard
input isn't as asynchronous as one would like.
Only process key press events: key releases are ignored. Without
this `nc 127.0.0.1 1234` won't receive anything from the server
until the local user presses a key.
In the default case, which now includes disk files and character
files, detect polling for reads as well as writes. Without this
`nc 127.0.0.1 1234 <local_file` doesn't work.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Execute a remote command on a Windows server using ssh:
~$ ssh localhost 'echo hello'
rmy@localhost's password:
hello
If such a command is run from a busybox-w32 shell the console enters
a strange mode when the command completes.
Attempt to recover by setting the console back to a default mode.
- This doesn't work in a legacy console.
- The new mode may not be _exactly_ correct, but it's better than how
ssh leaves it.
Costs 80-96 bytes.
(GitHub issue #288)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As noted in commit 2d848eba5 (ash: fix CRLF handling), removing
CRs from CRLF pairs in preadbuffer() is complicated by the
possibility that a CRLF pair might be split across the boundary
between buffers.
Add a wrapper around calls to nonblock_immune_read() to allow for
this.
Adds 104-128 bytes.
(GitHub issue #280)
|
|
|
|
|
|
|
| |
Commit 4b894b60a doesn't seem to have worked out. Revert it and
the fix in 6e0a6b7e5.
We're now back to removing CRs unconditionally from shell scripts.
|
|
|
|
|
|
|
|
|
| |
Commit 329f907b2 (ash: only reset ANSI emulation in interactive
loop) claimed to move resetting of ANSI emulation up into the
main interactive loop. Unfortunately it *just* missed the if-block
for interactive mode.
Put the call to skip_ansi_emulation() in the right place.
|
|
|
|
|
| |
Rearrange code to avoid unnecessary tests when the environment
variable BB_SKIP_ANSI_EMULATION is set.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When running the busybox-w32 shell in ConEmu, if:
- ANSI emulation is disabled (which it will be, by default)
- a non-builtin command is run
there is a window of a few seconds after the command completes during
which ConEmu is in XTerm mode. During this time any attempt to use
the arrows keys will result in [A[B[C[D appearing. This appears to
be a common problem:
https://github.com/Maximus5/ConEmu/issues/2316
Try to detect if we're running under ConEmu and alter the default
behaviour to prefer ANSI emulation. The user can override this
preference by setting BB_SKIP_ANSI_EMULATION if desired.
By a quirk of fate, old MSYS2 programs (from 2021) which required
a workaround in busybox-w32 (commit 54d2ea4b4) are immune to the
problem with ConEmu.
(GitHib issue #287)
|
|
|
|
|
| |
In skip_ansi_emulation() only call SetConsoleMode() if the new
mode differs from the current mode.
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 54d2ea4b4 (ash: reset ANSI emulation at prompt) worked
around a problem with MSYS2 applications. This seems to have
been fixed in more recent versions of MSYS2 but there's still
value in retaining the workaround for other such cases.
However, the call to reset ANSI emulation is probably being made
more often than necessary. Move it out of setprompt_if() and into
the main shell interactive loop.
|
|
|
|
|
|
| |
The change introduced by commit 4b894b60a (ash: change CRLF handling)
failed to detect the end of a here document with a CRLF line ending.
Add the necessary check.
|
|
|
|
|
|
|
|
|
|
| |
Commit 88965fe20 (win32: use ACL check to clarify write permission)
added code to check if a file had write permission due to an ACL
entry.
When running with elevated privileges this check is unnecessary as
"user" permissions will be sufficient. This also prevents write
permission for "other" being set without respecting umask.
|
|\ |
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
check_and_run_traps 229 278 +49
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Found one case where SIGHUP does need some handling.
ash does not restore tty pgrp when killed by SIGHUP, and
this means process which started ash needs to restore it,
or it would get backgrounded when trying to use tty.
function old new delta
check_and_run_traps 214 229 +15
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Kernel should do the right thing.
(ash and dash do not have special SIGHUP handling.)
function old new delta
check_and_run_traps 278 214 -64
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
record_pending_signo 32 63 +31
lineedit_read_key 231 224 -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 31/-7) Total: 24 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
get_file 185 201 +16
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Need to divide by (1<<32), not by (1<<32)-1.
Fraction of 0xffffffff is not 1 whole second.
function old new delta
.rodata 105264 105268 +4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The 32-bit integer part of the NTP timestamp overflows in year 2036,
which starts the second NTP era.
Modify the timestamp conversion to shift values between 1900-1970 (in
the first era) to the second era to enable the client to measure its
offset correctly until year 2106 (assuming 64-bit time_t).
Also update the conversion from double used when stepping the clock to
work with 64-bit time_t after reaching the maximum 32-bit value in 2038
and the server conversion to work correctly in the next NTP era.
function old new delta
lfp_to_d 51 64 +13
step_time 326 332 +6
.rodata 105260 105264 +4
d_to_lfp 100 86 -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 23/-14) Total: 9 bytes
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The memcpy invocations in the subCommand function, modified by this
commit, previously used memcpy with overlapping memory regions. This is
undefined behavior. On Alpine Linux, it causes BusyBox ed to crash since
we compile BusyBox with -D_FORTIFY_SOURCE=2 and our fortify-headers
implementation catches this source of undefined behavior [0]. The issue
can only be triggered if the replacement string is the same size or
shorter than the old string.
Looking at the code, it seems to me that a memmove(3) is what was
actually intended here, this commit modifies the code accordingly.
[0]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13504
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As noted in commit 2d848eba5 (ash: fix CRLF handling) all CRs are
removed when scripts are read. Allow an alternative approach
(configurable at build-time, enabled by default):
- Do not strip CRs from input.
- Treat CR as similar to space or tab in base syntax mode.
- Adjust pgetc_eatbnl() to handle backslash-CRLF in the same way
as backslash-LF.
With these changes scripts containing CRLF line endings are more
likely to work.
Adds 48-56 bytes.
(GitHub issue #285)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
vim has the 'binary' option and corresponding '-b' command line
flag. These allow files to be opened in binary mode, ignoring
the 'fileformats' setting and treating all files as of type
'unix'.
Add these to busybox-w32 vi so it's possible to edit files which
have a mixture of different line endings.
Costs 80-112 bytes.
(GitHub issue #285)
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
For some reason the 'fileformat' option was made read-only when
it was introduced in commit 420afde92e (vi: add fileformats option).
I think I'd read some vim documentation that made it seem more
complicated than it really is.
Costs 48 bytes.
|
| |
| |
| |
| |
| | |
A misplaced #endif in ash and the wrong sense of a test in
parse_config.c broke the POSIX build.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Assignment of shell output to a macro ('!=') was originally a
non-POSIX extension. It later became a POSIX 202X feature.
However, the implementation failed to include the additional
POSIX requirement that leading whitespace is removed from the
shell output.
Neither GNU make nor bmake strip leading whitespace. Implement
this behaviour as a non-POSIX extension.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Only remove CRs that are part of a CRLF pair in the output of
command substitution.
It would be nice to do the same in preadbuffer() but there's a
small chance the CRLF might be split between buffers.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Ensure a trailing CR is only removed if it precedes a LF.
The two cases at issue are intended to read complete lines and remove
the line terminator. In the normal case a trailing LF will be present
so removing the CR unconditionally worked. However, if the last line
of a file was missing its LF or if a NUL was detected (in the case of
xmalloc_fgetline()) the CR might have been removed without justification.
|
| |
| |
| |
| |
| |
| |
| | |
Fix remove_cr() so it only removes CRs which are part of a CRLF
pair, not every CR.
Add a test case for the shell.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Previous efforts at handling DOS-style line endings in awk have
included commits ee7e00dc5 and 1a3717342.
The use of remove_cr() is unwise:
- It's overzealous, removing all CRs, not just those in CRLF pairs.
- Even if that were fixed awk reads input in chunks. There's a
remote chance a CRLF might appear at a chunk boundary and be
missed.
remove_cr() will be fixed separately. In awk treat all data input
as being in text mode.
Skipping CRs in skip_spaces() is also flawed. Instead read scripts
in text mode.
Add a couple of test cases. One of these (awk backslash+CRLF eaten
with no trace) fails without this patch.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 82f0d19b1 (diff: implement --binary flag) was both over-
complicated and incorrect. If stdin was seekable it was left in
binary mode even if the --binary flag wasn't supplied.
Always open files in binary mode. Only switch to text mode at the
last moment, if necessary.
Saves 48 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The busybox-w32 shell initialises HOME when it starts. However,
if applets are run outside the environment provided by the shell
they may find HOME is unset. This caused a problem for 'vi' as
it was unable to locate its .exrc.
If HOME isn't available in the environment make getenv(3) provide
a sensible default value. The shell must use the *real* getenv(3)
when determining if HOME is already set.
Also, unrelated to the above, the shell shouldn't treat failure of
getpwuid(3) as a fatal error.
Costs 72-80 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
On Windows GNU diff uses text mode for input and output. It also
has the '--binary' flag to use binary mode instead. On Unix binary
mode is the default and the flag does nothing.
Alter diff to use text mode by default for input (though not output,
let's not go overboard). Add the '--binary' flag to override this.
Costs 96-160 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Use FILE_SHARE_READ when opening a file to check if it's an
executable. Without that other processes running in parallel
might be unable to access the file.
(GitHub issue #284)
|
| |
| |
| |
| |
| | |
This allows additional flexibility when another 'make' program is
present.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit f261d2d27 (make: make + sh configuration) added 'pdpmake'
as an alias for 'make'.
It should have been possible to include 'pdpmake' in a build without
also including 'make'. Adjust the build configuration so this works
as intended.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 7fb95a2a5 (win32: try to get link count for directories)
allowed stat(2) to report accurate values of st_nlink for
directories.
There are only a couple of places in busybox-w32 where these values
are required. Disable counting of subdirectories by default and
only enable it when necessary.
Microsoft kindly provide directories to test edge cases like this:
C:/Windows/WinSxS (contains many subdirectories)
C:/Windows/WinSxS/Manifests (contains many files)
Adds 84-112 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The function get_proc_addr() facilitates dynamic loading of functions
from DLLs. In the event of failure it set errno to ENOSYS.
This is sometimes useful, such as in the implementations of link(2),
symlink(2) and realpath(3). However, many other uses of lazy loading
can recover from failure or simply don't care. In these cases setting
errno is unnecessary and may be counterproductive.
(GitHub issue #283)
|