| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
Set 'noconsole' to match the actual state of the console (normal/
iconified) when the shell is started. Thus ShowWindow() will only
be called if the actual state differs from the default or user
defined state.
Costs 20-24 bytes.
(GitHub issue #325)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
FEATURE_UTF8_MANIFEST enables Unicode args and filenames on Win 10+.
FEATURE_UTF8_INPUT allows the shell prompt to digest correctly
Unicode strings (as UTF8) which are typed or pasted.
This commit adds support for building with FEATURE_UNICODE_SUPPORT
(mostly by supporting 32 bit wchar_t which busybox expects):
- Unicode-aware line-edit - for the most part cursor movement/del
being (UTF8) codepoint-aware rather than assuming that one-byte
equals one-char-on-screen.
- Codepoint-aware operations in some other utils, like rev or wc -c.
- When UNICODE_COMBINING_WCHARS and UNICODE_WIDE_WCHARS are enabled,
some screen-width-aware operations, like with fold, ls, expand, etc.
The busybox Unicode support is incomplete, and even less so with the
builtin libc replacement functions, like wcwidth, which are active
when UNICODE_USING_LOCALE is unset (mingw lacks those functions).
FEATURE_CHECK_UNICODE_IN_ENV should be set so that Unicode is not
hardcoded but rather depends on the ANSI codepage and some env vars:
LC_ALL=C disables Unicode support, else it's enabled if ACP is UTF8.
There's at least one known issue where the tab-completion-prefix-case
is not updated correctly, e.g. ~/desk<tab> completes to ~/desktop/
instead of ~/Desktop/, because the code which handles it exists
only at the non-unicode code paths, but that's not very critical.
That seems to be the only case where mingw-specific code is disabled
when Unicode is enabled, but there could be other unknown issues.
None of the Unicode options is enabled by default, and the next
commit will make it easier to create a build which supports Unicode.
|
|
|
|
|
|
|
|
|
| |
Implement clock_settime(2) and enable the '-s' option to allow
the system time to be set. This requires elevated privileges.
The code in date.c is now identical to upstream BusyBox.
Costs 256-272 bytes.
|
|
|
|
|
|
|
| |
The 'read' shell built-in echoed console input to stdout. Echo
directly to the console instead.
Costs 124-136 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add wrappers for the following input functions with conversions
for console input. Applications suitable for testing these changes
are appended in brackets.
- getchar (xargs)
- fgetc (tac)
- getline (shuf)
- fgets (rev)
Costs 112-120 bytes.
|
|
|
|
|
|
|
| |
Some applets use fread(3): dd and od, for example. Perform the
necessary conversion when input is coming from the console.
Costs 96-112 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since commit 597d31ee (EURO_INPUT), ReadConsoleInputA is the default.
The main problem with that is that if the console codepage is UTF8,
e.g. after "chcp 65001", then typing or pasting can result in a crash
of the console itself (the Windows Terminal or cmd.exe window closes).
Additionally and regardless of this crash, ReadConsoleInputA is
apparently buggy with UTF8 CP also otherwise.
For instance, on Windows 7 only ASCII values work - others become '?'.
Or sometimes in Windows 10 (cmd.exe console but not Windows terminal)
only key-up events arrive for some non-ASCII codepoints (without
a prior key-down), and more.
So this commit implements readConsoleInput_utf8 which delivers UTF8
Regardless of CP, including of surrogate pairs, and works on win 7/10.
Other than fixing the crash and working much better with UTF8 console
CP, it also allows a build with the UTF8 manifest to capture correctly
arbitrary unicode inputs which are typed or pasted into the console
regardless of the console CP.
However, it doesn't look OK unless the console CP is set to UTF8
(which we don't do automatically, but the user can chcp 65001),
and editing is still lacking due to missing screen-length awareness.
To reproduce the crash: start a new console window, 'chcp 65001', run
this program (or busybox sh), and paste "ಀ" or "😀" (U+0C80, U+1F600)
#include <windows.h>
int main() {
HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
INPUT_RECORD r;
DWORD n;
while (ReadConsoleInputA(h, &r, 1, &n)) /* NOP */;
return 0;
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, console input was converted to the ANSI codepage using
OemToChar[Buff], and ANSI to console conversion used CharToOem[Buff].
However, while typically true by default, it's not guaranteed that
the console CP is the same as the OEM CP.
Now the code uses the console input/output CP as appropriate instead
of the OEM CP. It uses full wide-char conversion code, which was
previously limited to FEATURE_EURO, and now may be used also otherwise.
While at it, the code now bypasses the conversion altogether if the
src/dst CPs happen to be identical - which can definitely happen.
Other than saving some CPU cycles, this also happens to fix an issue
with the UTF8 manifest (in both input and output), because apparently
the Oem/Char conversion APIs fail to convert one char at a time (which
is not a complete UTF8 codepoint sequence) even if both the OEM and
the ANSI CPs are UTF8 (as is the case when using UTF8 manifest).
Conversion is also skipped:
- if the converted output would be longer than the input;
- if the input length is 1 and the input is multi-byte.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allow current busybox-w32 to build with the CentOS 6 version of
mingw-w64.
- Fix declaration of setlinebuf(). (GitLab issue 116)
- Define ENABLE_VIRTUAL_TERMINAL_INPUT. (GitLab issue 117)
- Define IO_REPARSE_TAG_APPEXECLINK.
- Avoid a compiler warning in coreutils/shuf.c.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 2b4dbe5fa (libbb: speed up bb_get_chunk_from_file()) speeded
up grep by a factor of two. However, it introduced a call to
OemToCharBuff() in bb_get_chunk_from_file() which didn't have the
fix for the euro symbol from commit 93a63809f9 (win32: add support
for the euro currency symbol).
Export the fixed version of OemToCharBuff() and use it.
Saves 8 bytes (64-bit), adds 28 bytes (32-bit)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously the 'noconsole' shell option could only be set as a
shell command line option. Allow it to be changed from within
the shell by 'set -o noconsole' or 'set +o noconsole'.
The console window is now minimised rather than hidden. This
makes it easier for the user to access the console when 'noconsole'
is in effect.
Adds 8-32 bytes.
(GitHub issue #325)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 9db9b34ad (win32: ignore ctrl-c in parent of execve(2))
prevented a parent process from reacting to Ctrl-C while it was
waiting for its child to complete. This avoids the problem where
a shell and an interactive child end up competing for input after
a Ctrl-C.
However, a child process which isn't attached to the console
(a GUI application, for example) can't then be killed by Ctrl-C.
Instead of completely ignoring Ctrl-C give the parent a handler
which detects if its child is attached to the console. If so it's
left to handle Ctrl-C itself and the parent ignores the interrupt.
If not the parent terminates the child and all its children as if
by SIGINT.
Costs 200 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use an exit code of the form (signal << 24) when a process exits
due to a signal. This replaces the previous use of (signal + 128).
This makes it easier to distinguish exit codes from signals.
Allow kill(2) to handle all defined signals, not just EXIT, TERM
and KILL.
The kill and timeout applets now accept any defined signals.
Convert certain Windows status codes Unix-style signal codes.
In ash:
- Exit as if with SIGINT in raise_interrupt() rather than call
raise(SIGINT). The latter returns an exit code of 3.
- Detect if a child process exits as if with SIGINT. If not and if
the parent is an interactive top-level shell, reset pending_int.
This prevents the parent from seeing an INT if the child hasn't
reported it exited due to INT. (Probably due to it being an
interactive shell.)
Costs 132-136 bytes.
|
|
|
|
|
|
|
| |
There are two places where a copy of an argv array is made with
extra space at the start. Move this code into a function.
Saves 56-64 bytes.
|
|
|
|
|
|
|
| |
Export the function xappendword() from make. Use it in drop and
watch.
Saves 8-80 bytes, an unusually large disparity.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The tab-completion code treated all matches as case-insensitive
because that's how Microsoft Windows handles filenames.
This is now inadequate, as shell builtins, functions and aliases
are case sensitive.
Modify the treatment of case-sensitivity in tab completion:
- Track whether each potential match is case-insensitive (filename)
or case-sensitive (shell builtin, function or alias).
- When comparing matches use a case-insensitive comparison if either
value is a filename. Otherwise use a case-sensitive comparison.
Adds 64 bytes.
|
|
|
|
|
|
|
|
|
|
|
| |
It's fairly common for shell scripts to trap this set of signals:
EXIT HUP INT QUIT TERM (or the numeric equivalent: 0 1 2 3 15)
Add definitions for SIGHUP and SIGQUIT. We don't take any action
if traps are defined for them, but at least scripts won't fail.
(GitHub issue #303)
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 93a63809f9 (win32: add support for the euro currency symbol)
caused all invocations of busybox-w32 to change code page 850 to
858. This has been known to cause problems with fonts in PowerShell
(GitHub issue #207).
Delay changing the code page until an i/o operation is imminent.
Instances of PowerShell started by the `drop` applet during ssh login
thus no longer have their code page adjusted.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The 'drop' alias for 'runuser' relaxes a number of constraints
that were introduced for compatibility:
- It works even if the current process doesn't have elevated
privileges.
- It isn't necessary to specify the name of the user.
- Any command can be invoked, not just the BusyBox shell.
- If the command doesn't specify a path 'drop' will first look for
a BusyBox applet then search PATH.
Adds 320-336 when built along with runuser.
(GitHub issue #240)
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a function, file_is_win32_exe(), to detect if a path refers
to an executable. It tries adding extensions if necessary.
Use this in a number of places to replace common code of the form
path = alloc_ext_space(cmd);
if (add_win32_extension(path) || file_is_executable(path))
Saves 32-48 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a cut down, Windows-specific implementation of `runuser` from
util-linux.
This allows elevated privileges to be dropped when running in an
SSH session. It also works when using `su` or starting busybox-w32
'as administrator'.
There are complications:
- The method used to drop privileges leaves the access token in the
TokenIsElevated state. Detecting this is likely to be fragile.
- The unprivileged shell is started by CreateProcessAsUserA(). In
older versions of Windows this has to be loaded dynamically.
Adds about 900 bytes.
(GitHub issue #240)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 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.
|
|
|
|
|
|
|
|
|
| |
Microsoft Windows' setvbuf() doesn't support line buffering and
doesn't accept 0 as a valid value for the buffer size argument.
Replace the old macro definition with an implementation that
doesn't do anything. It's only used if debug is enabled in ash
so there's no effect on the default build.
|
|
|
|
|
|
|
| |
Since vfork(2) is never used in busybox-w32 there's no need to
declare it. Doing so provokes clang to issue a warning.
(GitHub issue #239)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 605972390 (win32: handle Unix-style absolute paths for
executables) added special treatment of paths for executables
starting with a slash. Such paths are absolute on Unix but are
relative to the current drive on Windows. On reflection this
commit did more than necessary. Later commits provided special
treatment only for paths starting with locations traditionally
used to contain binaries on Unix. This is probably sufficient.
Problems introduced by commit 605972390 include:
- If the current drive isn't the system drive tab completion of a
command starting with a slash confusingly references the system
drive.
- Building busybox-w32 with w64devkit fails on drives other than
the system drive.
Revert the changes introduced by commit 605972390.
This saves 192 bytes.
(GitHub issue #239)
|
|
|
|
|
|
|
|
| |
If a file is a junction or symlink return its tag in the st_tag
member of struct stat.
get_symlink_data() and is_symlink() also return the tag or zero,
as appropriate.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a Windows-specific applet to create a directory junction.
Usage: jn DIR JUNC
where DIR must be an existing directory on a local drive and JUNC
must not currently exist.
There isn't a simple WIN32 API to create directory junctions.
The implementation of mklink in ReactOS provided useful inspiration.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change how 'which' detects if it was run from a standalone shell:
the shell passes the undocumented '-s' option. This is stricter
and more reliable than the previous method of checking the name
of the binary.
Add a function to determine the binary associated with a given
applet name. This makes it possible for 'which' and 'command -v'
to list the correct binary even for applets other than 'busybox'.
For example, when the binary is called 'sh.exe' 'which sh' will
report its path.
In standalone shell mode 'command -V' and 'type' now report "xxx
is a builtin applet" rather than "xxx is xxx", which is true but
not very illuminating.
(GitHub issue #248)
|
|
|
|
|
|
|
|
|
| |
Provide a WIN32 implementation of clock_gettime(2), though only
with support for CLOCK_REALTIME. This makes it possible to enable
FEATURE_DATE_NANO which adds support for the %N date format.
MinGW-w64 has clock_gettime(2) but it's in the winpthreads library
and we don't want to bother with that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Upstream commit 94eb1c4dc (libbb: better coreutils compatibility
for realpath) made some changes to xmalloc_realpath_coreutils().
This now needs to be updated to handle Windows paths.
- Expose the macro is_unc_path() and part of the recent change to
bb_get_last_path_component_nostrip() as a separate funtion,
get_last_slash();
- Convert a couple of errors relating to network filesystems to
ENOENT;
- Adjust xmalloc_realpath_coreutils() to handle Windows directory
separators, relative paths and UNC paths.
|
|
|
|
|
| |
As the comment pointed out is_absolute_path() was misnamed. Rename
it to is_relative_path() and change the sense of all tests.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allow waitpid() to detect SIGTERM/SIGKILL by checking the (Windows)
status returned by GetExitCodeProcess() and updating the Unix
status to suit. This allows ash to detect when a process has been
'signalled'.
Provide our own implementation of strsignal(3) which returns
expanded text for SIGTERM/SIGKILL.
Costs 192 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Create mingw_strptime() to return timezone offset as a separate
argument (since Microsoft's struct tm doesn't have the required
member).
Import timegm() from musl.
Update parse_datestr() to use mingw_strptime().
Enable FEATURE_TIMEZONE in the default configuration.
GitHub issue #230.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Our realpath(3) implementation uses xmalloc_follow_symlinks() to
expand symlinks. This detects when symlinks are too deeply nested
but didn't set errno, so anything calling realpath(3) was unable to
say what had gone wrong. (For example, 'ls -L' or 'stat -L'.)
Set errno to ELOOP.
This then leads to the problem that Windows doesn't know about
ELOOP so reports 'Unknown error'. Add a replacement for strerror(3)
which returns a sensible message.
Costs 96 bytes.
|
|
|
|
|
|
|
|
|
|
| |
Provide a partial implementation of sync(2), so sync(1) can actually
do something in some circumstances:
- Only logical drives are handled.
- Flushing buffers requires administrative privileges. If run as
a normal user nothing will happen.
|
|
|
|
|
| |
Enable the sync applet by default. It doesn't actually do anything
useful but at least it prevents some scripts from failing.
|
|
|
|
| |
Avoid confusion between special devices and /dev/fd.
|
|
|
|
|
| |
The touch applet has been changed to use futimens(2)/utimensat(2).
Provide implementations of these for WIN32.
|
|
|
|
|
| |
Make is_absolute_path() a function rather than a macro and move it
from ash.c into mingw.c.
|
|
|
|
|
|
|
|
|
|
| |
Add a call to GetPerformanceInfo. Treat the SystemCache member of
the PERFORMANCE_INFORMATION structure as buffer RAM. Deduct it
from available RAM.
The numbers reported by 'free' move about in vaguely sensible
ways when I start and stop programs, though I still don't know
if they're in any way accurate.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is an experimental implementation of sysinfo(2)/free(1).
It uses the WIN32 API GlobalMemoryStatusEx() to obtain information
about memory.
It seems that the 'total pagefile' value includes total RAM as well
as pagefile and 'available pagefile' includes available RAM. So the
RAM values are deducted.
I've no idea what corresponds to Linux buffers and cache.
|
|
|
|
|
| |
Since there's only one call to mingw_spawn_forkshell() we might
as well just call spawnve() directly from ash.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Provide an implementation of symlink(2).
Calls to symlink(2) will fail in default Windows installations unless
running with elevated privileges. Failure to create a symlink when
extracting files from an archive is therefore treated as a non-fatal
error.
There are two ways to permit the creation of symlinks:
- Edit security policy to give users the 'Create symbolic links'
privilege. Unfortunately this doesn't work for users who are an
Administrator.
- Enable developer mode, which is available in later versions of
Windows 10.
The ability to create symlinks is not available in Windows XP
or ReactOS.
|
|
|
|
|
|
|
| |
There doesn't seem to be much advantage in having readlink(2) as a
configuration option. Making it unconditional reduces divergence from
upstream and allows the removal of a check for ENOSYS that's been in
busybox-w32 since the start.
|
|
|
|
|
| |
Don't compile some code that isn't currently supported for WIN32.
Saves 24 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On reflection, the previous commit may have been ill-advised. There
are many calls to open_read_close() and most shouldn't be able to
access special devices. (Though in practice only a few are enabled
in busybox-w32.)
Nonetheless, I've implemented a new mechanism which uses the macro
MINGW_SPECIAL() to mark calls to functions that are allowed to
access special devices.
An unrelated change is to avoid compiling fputs_stdout() in
coreutils/printf.c for the POSIX build.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Perform code page translation for fputc(3). It's only used in a
few places but is needed to fix things like:
$ echo € | dos2unix
Ç
$ paste -d € file1 file2
1Ç2
Unfortunately it breaks the inventive use of dos2unix in GitHub
issue #203.
|
|
|
|
|
|
|
|
|
|
| |
Revert commit 249f68e3c (win32: append '/' to bare drive name in
opendir).
Instead add better handling for paths of the form 'c:path' to ls
and expmeta() in ash.
Adds 64 bytes.
|