Commit Graph

13561 Commits

Author SHA1 Message Date
Stephen Heumann
d958c364f9 Merge commit 'f5add44981b43490376ea0dfed1420dba09a3a75' 2014-11-19 18:49:57 -06:00
Denys Vlasenko
f5add44981 typo fix in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-20 01:43:30 +01:00
Stephen Heumann
078f526df7 Fixes for terminal behavior on the GNO console 2014-11-19 12:52:05 -06:00
Stephen Heumann
ed1fff2c7b Merge commit '8a475def9e3e21f780ebcf07dd607b26ceb00ea8'
Includes a fix for a potential overflow when doing shell arithmetic division.
2014-11-18 21:16:35 -06:00
Stephen Heumann
60b6415214 Add our own implementation of fnmatch (taken from NetBSD), because the one in GNO 2.0.6's libc is broken.
The version in libc both matches things it shouldn't and doesn't match things it should, in (at least) cases where a pattern includes additional stuff beyond a *.
2014-11-18 20:51:04 -06:00
Denys Vlasenko
8a475def9e ash,hush: do not segfault on $((2**63 / -1))
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-18 14:32:58 +01:00
Denys Vlasenko
08a5dab181 ash: fix handling of negative start value in ${v:start:len}
function                                             old     new   delta
subevalvar                                          1140    1168     +28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-17 20:27:18 +01:00
Michael Tokarev
1a1143907c iproute: support onelink route option and print route flags
function                                             old     new   delta
print_route                                         1797    1865     +68
do_iproute                                          2097    2112     +15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 83/0)               Total: 83 bytes

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-17 19:35:41 +01:00
Denys Vlasenko
628f134fe7 exit with 127 if appled name wasn't found - it's more POSIXy
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-17 17:03:47 +01:00
Stephen Heumann
2fd57a3bdc Add basic support for getting input escape sequences from termcap. 2014-11-12 23:25:01 -06:00
Stephen Heumann
5f6121c091 Add initial support for getting terminal information from termcap, instead of hard-coding vt100-style codes.
This currently only supports output, and still doesn't quite display correctly in some cases.
2014-11-11 20:58:06 -06:00
Stephen Heumann
c37475dcbc Change vfork_and_run implementation to inspect the kernel's process tables to determine whether the child has really exec'd or exited.
This should avoid strange behavior due to races when the parent has resumed but the child is still running the exec* code in libc, which mainly manifests itself when running at low speed.

We also change to signaling the child's completion with SIGALRM, and setting an extra alarm in the parent in case the child doesn't actually do it.
2014-11-10 16:08:24 -06:00
Stephen Heumann
6d5e65b9df Fix corruption and hanging resulting from using _exit in forked processes by calling QuitGS directly instead.
GNO's _exit (contrary to its man page) does clean-up for stuff like the memory allocator, which is inappropriate in a forked child process and leads to hangs and crashes.
2014-11-09 18:49:58 -06:00
Stephen Heumann
b3a419646b Changes to handle the use of \r as newline on the IIgs. 2014-11-08 19:58:11 -06:00
Stephen Heumann
c8de71ae9d Changes so that hush can successfully re-execute itself:
*initialize the "environ" variable
*Reduce the stack size to 8192 (This should still be further reduced based on analysis of usage.)
2014-11-08 18:03:25 -06:00
Stephen Heumann
8f7e30fc8b Use prefix 9 instead of 1 to get the executable path, to avoid a length limitation. 2014-11-08 12:26:36 -06:00
Stephen Heumann
bff0844d44 Add code to get the path of the current executable, which we need to re-execute the shell.
On the GS, this uses GS/OS calls. Versions for OS X and Linux are also included.
2014-11-07 23:06:34 -06:00
Stephen Heumann
6bd3b140ea Misc. fixes related to file handling:
*Use .null instead of /dev/null
*Account for GNO's dup2(), which non-standardly returns 0 on success
*Always call open with appropriate number of arguments
*Use STDIN_FILENO instead of (implicitly) 0
2014-11-07 19:23:04 -06:00
Stephen Heumann
cae994bc22 Add an emulation of waitpid that should be better than the one in libc.
In particular, it will buffer information about children other than the one being waited for, so it isn't lost. It can also emulate a non-blocking wait by arranging to interrupt the wait with a signal.
2014-11-07 12:12:18 -06:00
Stephen Heumann
9bc48e5ebf Add synchronization to prevent the parent from running concurrently with the child until the child execs or terminates.
Our approach is to have the parent wait for SIGUSR2, and send that from the child just before it calls exec* or _exit.
2014-11-06 23:29:42 -06:00
Stephen Heumann
f52d5394bf Change code using 0/1/2 for stdin/stdout/stderr file descriptors to use macros instead, to properly deal with their different numbers on GNO. 2014-11-06 18:14:15 -06:00
Stephen Heumann
71b8b67d7d Make the "smallint" type "int" instead of "signed char." This works around an apparent compiler bug where a conditional isn't evaluated correctly. 2014-11-06 13:36:41 -06:00
Stephen Heumann
3b1d003ea7 Handle globals more simply, declaring the "G" structure containing them directly in shell/hush.c.
This allows the "G" struct to show up in the debugger, so it can easily be inspected.
2014-11-06 13:08:38 -06:00
Stephen Heumann
9320c1e704 Set things up so hush can be build with debug code turned on.
This involved breaking things up into more segments in debug mode, since the code is larger. I also had to remove some unused extern definitions, which were causing link errors when debug code was enabled.

To enable debug code, pass "DEBUG=1" to make or build.gs.
2014-11-06 11:42:17 -06:00
Stephen Heumann
a3426d2782 Remove C99isms in hush debug code to address compilation errors when debugging stuff enabled. 2014-11-05 23:28:24 -06:00
Stephen Heumann
2669183517 Define segments and make other adjustments in makefile.
At this point, hush can successfully build and run, although it doesn't work correctly.

The main Makefile is now dedicated to the GNO build. There's now a separate makefile for building on modern systems with GCC/Clang.
2014-11-05 22:26:33 -06:00
Stephen Heumann
77ded3c27c Use databank pragma around forked child entry methods, as required to ensure correct behavior. 2014-11-05 19:02:03 -06:00
Stephen Heumann
d583686459 Disable functionality for printing the time in the shell's prompt. This required strftime(), which is missing in GNO 2.0.6.
It would have been possible to add a version of strftime(), but it didn't seem worth it for this little bit of functionality. It should also be possible to get similar functionality by invoking an external program like "date" in PS1.
2014-11-05 18:00:35 -06:00
Stephen Heumann
c7f9c18893 Use GNO job control calls in place of unavailable POSIX ones. 2014-11-05 15:28:59 -06:00
Stephen Heumann
a3c32aaa73 Revise terminal control code to use ioctls supported by GNO instead of termios calls that aren't supported. 2014-11-04 19:53:40 -06:00
Stephen Heumann
7e5a584f0c Use alternative code (also from BusyBox) for checking if the user is in a group, avoiding a call to getgroups(), which isn't supported.
This could actually be further simplified, since GNO doesn't really have group-based file permissions, but I'll leave that until later.
2014-11-04 16:24:41 -06:00
Stephen Heumann
a60c64d6c7 Replace call to sigsuspend() (not in GNO) with sigpause(). 2014-11-04 15:41:05 -06:00
Stephen Heumann
42c6e9e095 Replace alloca usages with malloc in shell/glob.c. 2014-11-04 11:46:36 -06:00
Stephen Heumann
cbdfea4c97 Revise signal handling to work with GNO.
This involved using signal() rather than sigaction(), which GNO doesn't have. signal() doesn't have the signal-blocking feature of sigaction(), but I've tried to emulate it.
2014-11-04 10:45:28 -06:00
Michel Stam
d3fabf89d7 zcip: Add environment variable for overriding log functionality
function                                             old     new   delta
bb_logenv_override                                     -      70     +70
packed_usage                                       29969   30033     +64
zcip_main                                           1426    1431      +5
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/0 up/down: 139/0)             Total: 139 bytes

Signed-off-by: Michel Stam <m.stam@fugro.nl>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-11-04 12:19:04 +01:00
Stephen Heumann
036b92595c Address some link errors with various small changes.
The most significant change is to at use malloc instead of alloca in the code to evaluate shell arithmetic expressions in shell/math.c.
2014-11-03 23:29:34 -06:00
Stephen Heumann
af402a28a4 Restructure macros in libbb/xatonum.c and its template file to work with the ORCA/C preprocessor.
Also, get rid of a use of long long.
2014-11-03 20:17:51 -06:00
Stephen Heumann
9850090331 Use STDERR_FILENO rather than 2 in debug print statements, so they'll properly go to stderr on GNO. 2014-11-03 19:20:20 -06:00
Stephen Heumann
32e9dccc33 Fix the implementation of vasprintf to work with ORCA/C's varargs implementation. Also, shrink the stack-allocated buffer in it.
This code could theoretically break if the ORCA/C varargs implementation changed, but it should be OK in practice.

Also removed some unused code in libbb/xfuncs.printf.c that includes potentially problematic varargs use (defining varargs functions but not necessarily calling va_start/va_end in them).
2014-11-03 16:08:43 -06:00
Stephen Heumann
bdafda3f97 Fixes to get libbb/getopt32.c to compile.
This disables long argument support, since that requires getopt_long(), which isn't included in GNO. There is a separate library available for it, but it's simpler to avoid depending on that.
2014-11-03 12:58:57 -06:00
Stephen Heumann
488a238ad7 Add an implementation of poll() written in terms of select(), to work around the lack of poll() on GNO.
This is a BSD-licensed poll() implementation by Brian M. Clapper. Its performance characteristics aren't as good as a "native" poll() would be, but this shouldn't be a problem in practice.
2014-11-03 12:26:43 -06:00
Stephen Heumann
4e47bee9d2 Change libbb/signal.names.c to use C89-style constructs for ORCA/C compatibility. 2014-11-02 23:15:17 -06:00
Stephen Heumann
9b98d32e66 Fix ORCA/C compatibility problems in libbb/lineedit.c. 2014-11-02 22:40:28 -06:00
Stephen Heumann
051b79efc1 Move all the source files to 15-character ProDOS-compatible file names.
Dmake gets confused if you use over-15-character file names, so they needed to be shortened to get it to work. While I was at it, I also switched _ to . in the filenames so they're fully ProDOS compatible.

The shell/hush_test directory (not needed to build the code) still uses ProDOS-incompatible file names.
2014-11-02 22:11:07 -06:00
Stephen Heumann
d4b2c3ce8b Various changes for GNO and ORCA/C compatibility. 2014-11-02 18:30:31 -06:00
Stephen Heumann
97e65e3480 Remove C99isms from coreutils/test.c.
It now compiles successfully with ORCA/C.
2014-11-02 00:39:21 -05:00
Stephen Heumann
a3d8a81bb0 Add makefile (which can be used on GNO or a modern system), and build scripts based on in. 2014-11-01 22:59:10 -05:00
Stephen Heumann
875b1bbd0e More GNO and ORCA/C compatibility fixes.
Everything in the shell directory now compiles.
2014-11-01 18:25:21 -05:00
Stephen Heumann
2464399542 Convert additional vfork calls to xvfork_and_run. 2014-11-01 16:59:17 -05:00
Stephen Heumann
d7a6168aa1 ORCA/C compat fixes. Variables must be at beginning of block. 2014-11-01 16:07:30 -05:00