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
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
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
c7f9c18893
Use GNO job control calls in place of unavailable POSIX ones.
2014-11-05 15:28:59 -06:00
Stephen Heumann
a60c64d6c7
Replace call to sigsuspend() (not in GNO) with sigpause().
2014-11-04 15:41:05 -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
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
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
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
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
Stephen Heumann
3577d48e74
Change the ARRAY_SIZE macro to work around an ORCA/C limitation.
2014-11-01 15:47:17 -05:00
Stephen Heumann
2b0d727f39
Include glob implementation from dietlibc.
...
GNO doesn't actually implement glob, although it has a header for it. The GNO header is from an old BSD version and is missing some constants we need, so don't use it.
2014-11-01 14:27:52 -05:00
Stephen Heumann
f6c7fdc027
GNO/ORCA compatiblity: remove final comma in enums, and appropriately define stuff that GNO doesn't have in platform.h.
2014-11-01 14:22:47 -05:00
Stephen Heumann
3709307794
Get rid of varargs macros in hush.c.
2014-11-01 11:25:19 -05:00
Stephen Heumann
8f6869ae25
Miscellaneous changes for ORCA/C and GNO compatibility, mainly removing C99isms.
...
At this point, ORCA/C can process the main header files, and some smaller source files compile without errors.
2014-11-01 09:46:02 -05:00
Stephen Heumann
6c2c9d8865
Get rid of long longs in the the hush code (but not yet in the libraries)
2014-10-27 14:09:00 -05:00
Stephen Heumann
16c89af688
Change vfork calls to use vfork_and_run operation with GNO-compatible semantics
2014-10-27 13:10:11 -05:00
Stephen Heumann
e61b4040ec
Make char unsigned, as busybox is designed for (and as ORCA/C does)
2014-10-27 00:48:59 -05:00
Stephen Heumann
a00ca4770f
Eliminate or disable all the warnings given by clang -Wall
2014-10-26 23:30:51 -05:00
Stephen Heumann
ef1a853400
Minimal changes to enable hush-only builds on OS X
2014-10-26 21:14:47 -05:00
Denys Vlasenko
841f8331d7
ash,hush: run reinit_unicode() only if makes sense
...
With static Unicode support, no need to check $LANG et al.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-13 10:09:49 +02:00
Denys Vlasenko
c538d5bcc3
hush: make ${#var} unicode-aware
...
This mimics bash
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-08-13 09:57:44 +02:00
Denys Vlasenko
3fa97af7cc
ash,hush: set $HOSTNAME is bash compat. Closes 7028
...
function old new delta
hush_main 1056 1128 +72
ash_main 1442 1487 +45
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-15 11:43:29 +02:00
Denys Vlasenko
2bba591991
hush: make "true" built-in
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-03-14 12:43:57 +01:00
Denys Vlasenko
8bd810bd27
hush: typo fixes in comments
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-11-28 01:50:01 +01:00
Denys Vlasenko
e95738f635
typo fix in comment
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-08 03:13:08 +02:00
Denys Vlasenko
2301d127a2
unicode: check $LC_CTYPE too to detect Unicode mode
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-05 22:00:57 +02:00
Denys Vlasenko
3e7ecb179b
unicode: check $LC_ALL to detect Unicode mode, not only $LANG
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-02 17:30:23 +02:00
Denys Vlasenko
ff463a885d
hush: fix build failure if FEATURE_EDITING=y && !HUSH_INTERACTIVE
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-05-12 02:45:23 +02:00
Flemming Madsen
d96ffda62e
ash,hush: history builtin
...
function old new delta
show_history - 39 +39
builtin_history - 16 +16
historycmd - 13 +13
bltins1 312 324 +12
builtintab 336 344 +8
popstring 134 140 +6
hush_main 1048 1046 -2
ash_main 1398 1396 -2
size_from_HISTFILESIZE 44 40 -4
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 3/3 up/down: 94/-8) Total: 86 bytes
Signed-off-by: Flemming Madsen <busybox@themadsens.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-07 18:47:24 +02:00
Denys Vlasenko
3beab83e4f
hush: fix for "while false && true; do echo BUG; break; done". closes 6170
...
function old new delta
run_list 959 941 -18
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-07 18:16:58 +02:00
Denys Vlasenko
88b532d59a
hush: source builtin should override $N only if it has args
...
function old new delta
builtin_source 174 184 +10
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-17 14:11:04 +01:00
Denys Vlasenko
6830ade6aa
whitespace fixes. no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 13:58:01 +01:00
Denys Vlasenko
60cb48ca50
whitespace cleanup. no code changes
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 15:57:44 +01:00
Denys Vlasenko
9d75370238
hush: remove sighandler_t definition hack, platform.h has it too
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-26 10:59:01 +02:00
Denys Vlasenko
8cab66730a
fix build breakage found by randconfig
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-20 14:48:00 +02:00
Denys Vlasenko
0d6bbb0497
hush: remove unused member struct command::is_stopped
...
function old new delta
builtin_umask 133 132 -1
checkjobs 551 544 -7
builtin_fg_bg 291 267 -24
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-03-27 14:32:48 +02:00