Commit Graph

214 Commits

Author SHA1 Message Date
Eric Andersen
5c66d06104 Explicitly call setsid() 2001-06-26 23:16:31 +00:00
Eric Andersen
a90f20b1c3 Don't choke if /etc/profile is not available 2001-06-26 23:00:21 +00:00
Glenn L McGrath
78b0e379d7 Vladimir's last_patch_15 2001-06-26 02:06:08 +00:00
Eric Andersen
6c947d289f Fix the code for establishing a controlling terminal.
-Erik
2001-06-25 22:24:38 +00:00
Eric Andersen
2d848a476a This should finish off the job control issues with lash. Make certain
we have a controlling terminal...
 -Erik
2001-06-25 17:11:54 +00:00
Eric Andersen
52a97ca00c Some more cleanups. Of special importance, never free a pipe
that still has running jobs.  Instead, we ignore it and expect
it to be cleaned by the background job stuff.
 -Erik
2001-06-22 06:49:26 +00:00
Eric Andersen
c798b07762 Some cleanups for hush. Saves about 350bytes.
-Erik
2001-06-22 06:23:03 +00:00
Eric Andersen
8a646dd293 This commit guts lash, restoring it to what it was originally intended to do,
just be a simple command line interpreter with basic pipe, redirect, and job
control.  For all the more fancy things, people should use hush or ash.
 -Erik
2001-06-21 16:38:11 +00:00
Eric Andersen
04407e522b Another hush update from Larry:
Fixes the interaction between if/then/else/fi syntax and variables.
    I planned to do it right from the beginning, but my implementation
    was buggy.  Also adds the relevant test cases.  Also adds some old
    Matt Kraai variable test cases that got left out somehow.
2001-06-07 16:42:05 +00:00
Eric Andersen
817e73cb63 A patch from Larry to fix pathological things like '>""' 2001-06-06 17:56:09 +00:00
Matt Kraai
c616e53ca2 Don't close file descriptors when we are duplicating them. 2001-06-05 16:50:08 +00:00
Eric Andersen
4f6753e586 Cope gracefully when people type something, then hit ^C.
-Erik
2001-05-31 17:17:12 +00:00
Eric Andersen
4f990533e3 Patch from Vladimir to fix up autocompletion on a files/dirs with spaces in
them in the presence of a quoting.  Also revert my signal handling patch,
which seems to not solve the problem I thought it solved.
2001-05-31 17:15:57 +00:00
Eric Andersen
a813afc24f Plug another memory leak 2001-05-24 16:19:36 +00:00
Eric Andersen
a15dc15f12 Plug another memory leak in hush. This one showed up when backticked
commands were run.  This one was sure a bugger to find.
 -Erik
2001-05-23 23:46:09 +00:00
Eric Andersen
bf7df04ec1 Fix a massive memory leak in the run_list_test() function.
Rename run_list_test() as free_pipe_list().
Rename run_pipe_test() as free_pipe().
 -Erik
2001-05-23 22:18:35 +00:00
Eric Andersen
77d9268892 Patch from larry to fix some grammar errors. 2001-05-23 20:32:09 +00:00
Matt Kraai
bdd4eced84 Commit a patch by Larry Doolittle which fixes recursive calls to file_peek,
and improves some debugging messages.
2001-05-23 17:43:00 +00:00
Eric Andersen
57e6a49e5b Excellent. This patch from Larry fixes the behavior of hush
when builtins are included in pipes.
2001-05-22 22:34:51 +00:00
Eric Andersen
9978576f15 Fix this case. No, really this time.
unset FOO
    export FOO=bar
    FOO=baz
    echo "global env: " `env | grep ^FOO`
    echo "local env:  " `set | grep ^FOO`
 -Erik
2001-05-22 21:37:48 +00:00
Eric Andersen
aeb44c4da6 Fix a race. Sometimes by the time we got to checkjobs(), the
pipe struct had already been freed.  Return immediately if the
pipe is NULL.
2001-05-22 20:29:00 +00:00
Eric Andersen
816867858b Oops. Remove some debug noise I left in. 2001-05-22 19:23:35 +00:00
Eric Andersen
94ac244dea Updates from both Vladimir and Larry 2001-05-22 19:05:18 +00:00
Eric Andersen
004015e9c4 Patch from Lars Kellogg-Stedman <lars@larsshack.org> to fix bug
#1130 (i.e. When you turn on features it should always ADD features)
2001-05-21 20:30:51 +00:00
Eric Andersen
ada18ff0f5 The latest patch from Larry 2001-05-21 16:18:22 +00:00
Eric Andersen
9ffb7dd9a4 This is a patch from Vladimir:
> I rewrite *local_variable* function in hush.c with:
    > 1) remove many memory leaks
    > 2) add support read_only protect (require write builtin function for set this,
    > I write this special for variable HUSH_VERION=0.01)
    > 3) commad read set only local variable now
    > 4) remove many error messages if "set unset export" not defined variable
    > (bash syntax not put and set error code). Hmm, if I set result to -1, you hush
    > called waitpid and returned with error "no waitpid" ( i not found place this
    > error).
    > 5) destroy error in new version check xgetcwd()==NULL and set "(unknow)" -
    > this have error: crashe in next call `pwd`, but xgetcwd(not null) called
    > free(arg).
    > 6) next add integraion with libbb

Valdimir's patch missed two cases of local variable handling
    FOO=bar
    export FOO=baz
    unset FOO
and
    export FOO=bar
    FOO=baz
which were working before, so I fixed those two cases.
2001-05-19 03:00:46 +00:00
Eric Andersen
bfae2529b8 It turns out job control in both hush and lash was broken by the
signal handling in cmdedit.c.  Disabling it makes the shells behave
themselves again.  hush isn't quite there, but is getting close...
 -Erik
2001-05-17 00:14:27 +00:00
Matt Kraai
59df6f7398 Change 'printf("%s\n", ...)' into 'puts(...)'. Noted and patched in hostname.c
by Larry Doolittle.
2001-05-16 14:21:09 +00:00
Eric Andersen
bc604a2f41 Move init of a bunch of globals into main so we are at least
a bit more reentrant.
 -Erik
2001-05-16 05:24:03 +00:00
Eric Andersen
f72f562b2f Fix the behavior of local shell variables to match that of bash and ash.
-Erik
2001-05-15 23:21:41 +00:00
Eric Andersen
15649c11f3 Oops. I left in some debug noise. 2001-05-15 17:28:26 +00:00
Eric Andersen
20a69a77d2 Write set_local_var() and fixup lookup_param() so you can now use
shell local variables.
 -Erik
2001-05-15 17:24:44 +00:00
Eric Andersen
78a7c99f7f This patch covers one big part of variable handling.
$ a=b foo
should be handled correctly.
$ a=b
is parsed OK, but the actual variable setting is not
yet written.  Except for some weird exceptions related
to quoting rules, this code passes (matches ash behavior)
all the tests I threw at it.

If someone now writes set_local_var(), and updates lookup_param()
to match, we can claim success!

       - Larry
2001-05-15 16:30:25 +00:00
Eric Andersen
cfa88ecb72 Fix up some silly warnings 2001-05-11 18:08:16 +00:00
Eric Andersen
5f265b755a Fix a segfault in lash, hush, and cmdedit. Each of these used
xgetcwd, but did not check the return for a NULL, and then continued
to call strlen on the NULL when the cwd had been removed from under it.
 -Erik
2001-05-11 16:58:46 +00:00
Eric Andersen
9d94deabd3 Use xgetcwd 2001-05-11 16:36:03 +00:00
Eric Andersen
1a6d39b259 A few more structural updates for job control.
-Erik
2001-05-08 05:11:54 +00:00
Eric Andersen
0a36de0580 Fix a stupid segfault caused by dereferencing a NULL ptr.
-Erik
2001-05-08 04:25:46 +00:00
Eric Andersen
45e92ba2ce This patch from Evin Robertson <nitfol@my-deja.com> fixes export so it works.
This way leaks memory, but oh well.  We will probably fix that when we get
around to doing local variables.
2001-05-07 23:53:09 +00:00
Eric Andersen
83a2ae2184 More hush updates from Larry:
Update some comments.  Generate partial placeholders for the missing
    builtins.  Write builtin_umask.  Properly treat exec without arguments
    as a means to open/close files within the running script.  Implement
    "4<&-" that encodes for file descriptor closure.
2001-05-07 17:59:25 +00:00
Eric Andersen
2dcfba7117 Larry's variant on Evin Robertson's fix to what I messed up
trying to make job control work.  This fix makes it so that
hush doesn't error out when init hasn't set up job control,
as in when init=/bin/sh
2001-05-04 22:13:37 +00:00
Matt Kraai
d24f878546 Don't reset parents context when we encounter an terminator. Fixes
if true; then if true; then true; fi; fi
2001-05-04 21:20:20 +00:00
Eric Andersen
e5ffb911e8 If it fails to run a builtin, let it fall through to
exec the real thing.
 -Erik
2001-05-04 16:30:29 +00:00
Matt Kraai
80abc45182 Move up waitpid error check so that errno isn't clobbered by tcsetpgrp. 2001-05-02 21:48:17 +00:00
Eric Andersen
0fcd447d59 Some more job control updates. It will now sucessfully background
stuff.  Good luck getting things back into the foreground though...
 -Erik
2001-05-02 20:12:03 +00:00
Matt Kraai
20a3069ec0 Don't treat newline as pipe separator when processing substitutions. 2001-05-02 17:52:49 +00:00
Matt Kraai
9f8caf134f Fix $(...) construction. Noted and patched by Larry Doolittle
<ldoolitt@recycle.lbl.gov>.  I'm just a patch whore.  :)
2001-05-02 16:26:12 +00:00
Eric Andersen
bafd94f154 First pass at getting job control working. This gets the infrastructure
in place, but something is still missing/wrong in there.  Testing with
'grep foo &' seems to put _hush_ into the background.  Pondering...
 -Erik
2001-05-02 16:11:59 +00:00
Matt Kraai
1c8a59ab95 Use the current pgrp, not pid, when resetting the foreground process group.
Fixes bizarre suspension when executing `echo`.
2001-05-02 15:37:09 +00:00
Matt Kraai
f162e7d09d Don't segfault if the first word is the empty string. 2001-05-02 14:48:48 +00:00