Commit Graph

13657 Commits

Author SHA1 Message Date
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
Stephen Heumann 0c9ebf3839 Fix problem with the read builtin where it wouldn't finish until you typed an additional character beyond the return that was supposed to terminate it. 2014-12-14 22:06:27 -06:00
Stephen Heumann 26efb6c33e Add support for moving forward/backward one word with OA-left/right on GNO and Ctrl/Alt/Command-left/right on VT100-style terminals.
The support for OA-left/right on GNO uses the OA2META ioctl option to map OA-x to ESC x.

VT100-type terminal emulators have significant variations in what modifier combinations they'll pass through and what escape sequences they produce. Hopefully at least one of them works on just about everything.
2014-12-14 18:49:10 -06:00
Stephen Heumann 8bc7d9fb31 Fix lineedit to process down arrow key properly.
This was broken by the change to using CRMOD mode, which actually does mapping on input as well as output. The fix is to set the terminal to "vt100 arrow" mode, which is an undocumented option that translates arrows to vt100-style escape sequences (also used by gsh).

(Note that the earlier patch actually makes us use CRMOD mode most of the time, not non-CRMOD mode as the summary erroneously says.)
2014-12-14 17:25:04 -06:00
Stephen Heumann 3887b30719 Fix bb_put_cr on non-GNO (it wasn't flushing stdout before printing the CR, leading to the prior character not appearing). 2014-12-14 14:21:25 -06:00
Stephen Heumann 55302cd56c Change lineedit so the terminal isn't kept in CRMOD mode most of the time.
This is important because CRMOD mode prevents text from backgrounded programs from being printed properly. It also leaves the terminal in an inappropriate state if hush crashes or is killed.

For the time being, we still switch briefly to CRMOD mode when we want to print just a CR.
2014-12-14 12:40:46 -06:00
Stephen Heumann 4f7d95d896 Fix problems with editing of commands that extend to multiple lines. 2014-12-13 22:21:38 -06:00
Denys Vlasenko acb8be7217 tar: fix "tar -cJ" ignoring -J option. closes 7706
function                                             old     new   delta
tar_main                                             895     938     +43
vfork_compressor                                     206     191     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 43/-15)             Total: 28 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-12-11 15:34:02 +01:00
Stephen Heumann 038f37f9eb Enable "fancy echo," including echo -n and -e options. 2014-12-10 18:56:14 -06:00