Commit Graph

13665 Commits

Author SHA1 Message Date
Stephen Heumann
ad96f52394 Bump version to 1.0. 2015-01-25 16:11:15 -06:00
Stephen Heumann
8ab8709e6b Add code to kill stopped (or partially stopped) jobs with SIGHUP on exit.
POSIX says that _exit() should do this, but on GNO it doesn't. This implementation should match the POSIX behavior in most cases, although it's not exactly the same.

Gsh also kills jobs on exit, but does so whether they're stopped or not and uses SIGKILL.
2015-01-24 21:32:57 -06:00
Stephen Heumann
b2161dc4e1 Disable a bit of useless code.
Also, add a copyright notice for me in hush.c.
2015-01-24 18:56:25 -06:00
Stephen Heumann
acab757b9a Don't try to block SIGCHLD in the system() implementation.
The logic for this was broken (giving a signal number rather than a mask to sigblock), and if it wasn't broken then it would have caused the wait call to hang.

Blocking SIGCHLD is required by POSIX, but gsh doesn't do it, so existing GNO code shouldn't be relying on it.
2015-01-22 20:57:21 -06:00
Stephen Heumann
445a03527d Fix to make ^Z work for suspending processes when hush is the login shell.
The issue is that GNO's login (and other BSD-derived versions) start up the login shell with SIGTSTP ignored. Hush was recording this configuration and propagating it to its child processes, causing ^Z not to work. The fix is to not do that (for login shells only).

Also, set the system vector to run hush before running any of the startup scripts, in case something run in them uses it.
2015-01-22 17:43:45 -06:00
Stephen Heumann
6276d32088 Bump version number 2015-01-17 19:40:20 -06:00
Stephen Heumann
f91211baec Add a couple notes to README 2015-01-16 23:16:02 -06:00
Stephen Heumann
2eafa59ebc Better handling of really long commands.
Commands in the range of 16k-32k should now work, and commands longer than that should cause hush to die with an error message instead of corrupting stuff (at least in the simple cases I tested).

It would be possible to eliminate the 32k limit by using a type larger than "int" for lengths, but that would be a more invasive change.
2015-01-16 21:33:13 -06:00
Stephen Heumann
24b49d61e7 Update sample hushenv file, using "$@" so arguments with spaces will be handled properly. 2015-01-16 19:09:50 -06:00
Stephen Heumann
988683c572 Fix "wait" builtin to work correctly in no-parameters case
This was another issue where wait() was being called with SIGCHLD masked, and therefore never returning.
2015-01-16 18:14:55 -06:00
Stephen Heumann
d305e3b821 Fix a bug where numbers could be truncated to four decimal digits in certain circumstances.
This affected values from $RANDOM, and could potentially also result in corruption of pid values if they were large enough.
2015-01-15 21:28:35 -06:00
Stephen Heumann
bb88e739e5 Fix bug where using a 16-bit signal mask caused some signal handlers not to be installed.
This manifested itself in interactive hush shells getting suspended when ^Z was typed (and maybe also other ways).
2015-01-15 20:34:20 -06:00
Stephen Heumann
3d106c6708 In waitpid emulation, restart waiting after signals.
This matches the semantics the original hush code obtained by using the SA_RESTART flag when installing signal handlers, and avoids error messages about waitpid being interrupted.
2015-01-15 18:45:42 -06:00
Stephen Heumann
656769d136 Work around GNO libc's buggy sigprocmask implementation by defining our own version of it. This should fix issues where hush could hang in wait() calls.
The sigprocmask implementation in GNO 2.0.6 libc has bugs that cause it to never actually unblock signals that have been blocked. This was causing many signals to remain blocked when they shouldn't be, particularly after running signal handlers.

This problem combined with a kernel issue (wait() calls won't recognize that a child has finished if SIGCHLD is blocked) to cause hangs in certain conditions.

This patch works around these issues by defining our own non-buggy version of sigprocmask in place of libc's.
2015-01-15 18:02:33 -06:00
Stephen Heumann
f88111e789 Do newline conversion in the "echo" builtin. 2015-01-08 17:23:39 -06:00
Stephen Heumann
01890e4a42 Reset to normal cursor when the command prompt is printed.
This works around problems when programs change the cursor and don't restore it before exiting.
2015-01-08 17:10:46 -06:00
Stephen Heumann
b1044cfa8f Properly report exit status values with the high bit set (128-255).
These were being reported as strange values because the WEXITSTATUS macro from the GNO headers would erroneously sign-extend them.

Thanks to Kelvin Sherlock for posting an example that demonstrated this problem.
2015-01-04 15:45:25 -06:00
Stephen Heumann
ba87092078 Work around problem where hush would hang after another process was ^C'd while reading from the terminal.
I think this problem is probably due to a bug in GNO's implementation of select().

The workaround is not to use poll (which calls select) when reading a key with no timeout (which is the normal case for command-line input).
2015-01-01 23:16:26 -06:00
Stephen Heumann
b220322ac5 Fix so history files on ProDOS volumes actually get replaced and thus shortened when they reach their max size.
Also, reduce the default history size.
2015-01-01 22:11:38 -06:00
Stephen Heumann
3380dae27a If hush is invoked as a login shell, set up a handler so it will be invoked when system() is called. 2015-01-01 17:33:01 -06:00
Stephen Heumann
63f74a5ee7 Add sample startup scripts 2015-01-01 13:19:05 -06:00
Stephen Heumann
ba2aa925bc Fix sigaddset/sigdelset/sigismember macros to support signals above 16.
The versions in the GNO 2.0.6 headers are broken--they don't account for int being 16-bit, so they cut off the higher signals.
2014-12-28 16:06:45 -06:00
Stephen Heumann
01dbfccea6 Reset the terminal to our pgrp after groups, functions, and builtins, not just external command invocations.
This addresses a problem where something invoked in a group or function (e.g. gsh) could change the terminal's pgrp, and this would result in hush getting backgrounded.

We can still get strange behavior when a backgrounded child process changes the pgrp. Trying to deal with this would be inherently racy. Gsh also has problems in this scenario.
2014-12-28 12:22:37 -06:00
Stephen Heumann
9033a24562 Add support for additional startup files that will be sourced either always, for login shells, or for interactive shells. 2014-12-27 21:59:45 -06:00
Stephen Heumann
70ea37208b Merge with BusyBox 1.23.0.
The only substantive change is about when simple line input mode is used.

I also bumped the version number and included a GNO-version-specific component.
2014-12-27 13:33:41 -06:00
Stephen Heumann
2c496f0bf2 Update README 2014-12-27 11:45:27 -06:00
Stephen Heumann
88869883b0 Update makefile, adding in functionality that was in extra scripts 2014-12-27 11:33:31 -06:00
Stephen Heumann
f101f364bc Enable a couple optimizations that aren't reported to be buggy. 2014-12-27 10:07:53 -06:00
Stephen Heumann
5b1c69f8d6 Error handling in case termcap entry can't be found 2014-12-26 23:13:52 -06:00
Stephen Heumann
6dfc5eadb3 Changes to support GNO-style PATH in type and source commands, and in tab completion. 2014-12-26 21:49:55 -06:00
Stephen Heumann
4c37e05f0c Reduce stack size to 3k.
Hush uses recursion for (at least) parsing nested constructs like { ... }, so it's possible for pathological/malicious scripts to overflow the stack, but this should be enough for just about anything non-pathological (e.g. up to about 10 levels of nested { }).
2014-12-26 16:33:17 -06:00
Stephen Heumann
79371e2122 Update test-running script to work on GNO (although it seems to hang on some tests) 2014-12-25 15:36:05 -06:00
Stephen Heumann
3e96c3390f Check for TERM changes every time we read input.
Also, fix possible crashes when termcap entries aren't found.
2014-12-24 14:54:06 -06:00
Denys Vlasenko
6968e08123 Bump version to 1.23.0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-24 01:48:20 +01:00
Denys Vlasenko
ca9c4653a9 libbb: add sanity check in bb_arg_max()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-24 01:46:29 +01:00
Denys Vlasenko
11775edbfc randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-22 19:37:05 +01:00
Stephen Heumann
cdad130f39 Add a "prefix" builtin for setting GS/OS prefixes 2014-12-22 11:18:38 -06:00
Peter Kümmel
a6588fa102 Make it possible to override LOGIN_FAIL_DELAY in CONFIG_EXTRA_CFLAGS
Signed-off-by: Peter Kümmel <syntheticpp@gmx.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-22 01:55:54 +01:00
Denys Vlasenko
28634924f0 udhcpc: account for script run time
Based on the following user report:

I ran into an issue where I was seeing a long delay in the scripts called
in udhcp_run_script. I was using an old version of OpenWrt (kamikaze)
and a satellite modem. An NTP script was being called and the modem
would sometimes take a long time to respond to the DNS lookup when
it was offline.

This delay started affecting my lease time. The lease that I would
get from my satellite modem before it was online would be short:
only 60 seconds. The delay with NTP and the modem would typically
be about 18 seconds. This would cause the first DHCP renew request
from dhcpc to be a little late. Under certain circumstances,
I could even see the first DHCP renew to occur after the lease
had expired!

function                                             old     new   delta
udhcpc_main                                         2816    2837     +21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-21 16:10:22 +01:00
Baruch Siach
ad0d009e0c nanddump: don't show --bb in usage when disabled
The --bb options now depends on LONG_OPTS. Omit mentions of --bb from usage
text when LONG_OPTS is disabled.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-18 11:55:08 +01:00
Stephen Heumann
c37319db8a Fix problem where the system crashed as soon as you typed anything at the hush prompt in TMTerm or GSI.
The problem seemed to be that it crashes if the t_intrc special character is set to -1 on a pty. I worked around this by setting it to an obscure control character instead in that case.
2014-12-17 23:09:20 -06:00
Baruch Siach
e835afadfe nandwrite: fix build when long options are disabled
The Required_argument macro is only defined when long options are enabled.
Fixes the following build error:

miscutils/nandwrite.c: In function 'nandwrite_main':
miscutils/nandwrite.c:120:10: error: expected ',' or ';' before 'Required_argument'

Reported-by: Christian Kästner <kaestner at cs.cmu.edu>
Signed-off-by: Baruch Siach <baruch at tkos.co.il>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-17 17:02:37 +01:00
Stephen Heumann
dc3caf92e7 Use a ProDOS-compatible filename for saved history file on GNO. 2014-12-16 16:02:24 -06:00
Stephen Heumann
f873a5cb9f README format fix. 2014-12-15 21:48:31 -06:00
Stephen Heumann
d6f48f9104 Add README file 2014-12-15 21:46:21 -06:00
Stephen Heumann
787a84b7e8 Include copyright/license notices in all c files, including a BSD-style license for ones written from scratch by me. 2014-12-15 17:27:46 -06:00
Stephen Heumann
e96ed4b46a Update the makefile for building on modern *nix systems. Rename to "Makefile" so we can build with just "make."
Also remove an unused variable that clang was warning about.
2014-12-15 16:47:12 -06:00
Stephen Heumann
12d172a1d9 GNO Makefile updates
1) Rename to Makefile.mk
2) Use *.o rather than *.a for object files
3) Reduce stack size to 4096 (may reduce further later)
2014-12-15 16:35:34 -06:00
Ron Yorston
20cd31a2d7 lineedit: don't block when looking for escape sequence in vi-mode
In vi-mode lineedit tries to detect some escape sequences.
After the ESC it reads the next character to check for certain
values.  This read should have a timeout or a user-entered ESC to
switch to command mode doesn't properly handle the next character.

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-15 13:30:58 +01:00
Stephen Heumann
d0dd867542 Fix problem where trying to run a program on a nonexistent volume gave an unescapable 'insert disk' dialog.
This also gives more sensible error messages when trying to execute nonexistent files.
2014-12-14 22:37:12 -06:00