Commit Graph

727 Commits

Author SHA1 Message Date
christos
63cfe07dab PR/44229: Henning Petersen: Remove dup check for whitespace. 2010-12-13 16:54:04 +00:00
christos
7c0ceafd8c revert again, since this breaks libtool amongst other things. 2010-11-17 13:40:48 +00:00
christos
abc3b37046 PR/43469: Antii Kantee: test/util/sh/t_expand:strip fails.
Bring back fixes from revision 1.75:

- Fix a couple of bugs to make the following two echo statements print the
  same output as they should:

    line='#define bindir "/usr/bin" /* comment */'
    echo "${line%%/\**}"
    echo ${line%%/\**}

1. ISDBLQUOTE() was not working properly for non VSNORMAL expansions because
   varnest was incremented before the variable was completely parsed. Add
   an insub adjustment to keep track of that.
2. When we have a quoted backslash, we either need to escape twice, because
   one level of escaping will be stripped later (in the variable substitution
   case) or simply enter the backslash.
2010-11-16 18:17:32 +00:00
christos
af7c6886fd revert previous. breaks other stuff. 2010-11-14 19:49:16 +00:00
christos
082c42cb76 - Fix a couple of bugs to make the following two echo statements print the
same output as they should:

    line='#define bindir "/usr/bin" /* comment */'
    echo "${line%%/\**}"
    echo ${line%%/\**}

1. ISDBLQUOTE() was not working properly for non VSNORMAL expansions because
   varnest was incremented before the variable was completely parsed. Add
   an insub adjustment to keep track of that.
2. When we have a quoted backslash, we need to escape twice, because one
   level of escaping will be stripped later. (XXX: Do that when insub == 1
   only?)

- Make macros statements
2010-11-14 19:43:38 +00:00
christos
232829f42f don't core-dump if we cannot open the trace file. 2010-11-14 19:36:07 +00:00
stacktic
129baba091 Make sh build in debug mode 2010-10-29 17:06:53 +00:00
stacktic
6a6f2f47f8 Initialized flag field in struct alias (Fixed PR/43281) 2010-10-29 17:04:48 +00:00
christos
42fececd08 dprintf is claimed by posix. 2010-08-30 06:27:14 +00:00
christos
f69d85affc increase commented out debugging. 2010-08-30 06:26:59 +00:00
perry
7e5b4620db add bsd.subdir.mk 2010-08-22 02:21:31 +00:00
perry
9573f66f1d RCSIds 2010-08-22 02:19:07 +00:00
perry
ee256018ca build the tutoral 2010-08-22 02:09:36 +00:00
perry
32b1d940e0 Extremely extensive updates.
This document should now serve as a reasonable tutorial for the
modern POSIX shell. Comments and additional fixes for mistakes I may
have made are solicited.
2010-08-22 02:03:06 +00:00
perry
62dd025e10 Revive S.R. Bourne's original tutorial on using the Bourne Shell.
This initial commit consists of the files as they existed in 4.4BSD,
with the copyrights altered to reflect the subsequent BSD relicensing.
2010-08-22 01:58:16 +00:00
joerg
0597463e89 Don't quite +', -' and `/' in set -x output. 2010-07-19 01:15:17 +00:00
christos
eb956cbd4d need errno for the debug build. 2010-06-03 16:14:13 +00:00
christos
f82c1d73b2 set -e is supposed to work inside eval; skip EV_TESTED. 2010-06-03 16:06:48 +00:00
dholland
30dd36f330 Note that set -o tabcomplete requires either set -o emacs or set -o vi
to work.
2010-06-03 02:05:02 +00:00
joerg
6004702d47 \\ -> \e 2010-03-01 21:53:58 +00:00
christos
d464f08166 fix faulty logic in previous change. 2010-02-21 09:54:57 +00:00
christos
72f71b4cd6 default to the original behavior for $ENV unless POSIXLY_CORRECT is set. 2010-02-20 23:15:17 +00:00
christos
8752bdfe89 PR/42828: Richard Hansen: Don't evaluate ${ENV} if not interactive.
http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_03
2010-02-17 15:57:24 +00:00
he
76d4444c78 When using -lcurses, you also need -lterminfo.
This fixes the build for sun2, and also builds with LDSTATIC=-static,
since archive libraries don't record inter-library dependencies.
2010-02-06 23:45:24 +00:00
roy
98eb889579 Userland now builds and uses terminfo instead of termcap.
OK: core@, jdc@
2010-02-03 15:34:37 +00:00
wiz
2afd9d4a18 Bump date for cd -P support. 2010-01-01 21:46:31 +00:00
dholland
a5ced5a04b fix another typo 2010-01-01 19:51:19 +00:00
dholland
cd0a6973f8 Make the cd builtin accept and ignore -P, which is a kshism that has been
allowed to leak into POSIX and selects the behavior cd already implements.
Closes PR bin/42557 and also relevant to PR pkg/42168.

I suppose this should probably be pulled up to both -4 and -5...
2010-01-01 19:34:59 +00:00
dholland
87e87a1f8c fix typo 2010-01-01 18:09:16 +00:00
christos
e3fc7d5ba9 use .ORDER for rules that create multiple files. 2009-12-14 05:13:38 +00:00
uebayasi
b79e178285 Rewrite file generation rules using ${GENCMD}. No functional changes intended. 2009-12-11 08:39:42 +00:00
uebayasi
58b17edd41 Define dependencies of arith.[ch] on arith.y. 2009-12-07 16:22:41 +00:00
tsutsui
49ee47d09d Use %zu in printf format for size_t value. 2009-11-27 10:50:04 +00:00
gson
dddcd98c78 Removed return statement in parser action that caused a memory leak with
the new yacc, making "sh MAKEDEV -MM init" consume 27 MB of virtual memory
with the result that NetBSD could no longer be installed on a 32 MB system.
2009-11-13 13:49:09 +00:00
christos
5dfc26d510 use flex options instead of #defines 2009-10-29 14:21:40 +00:00
christos
10aa8c24e9 only for when trap if we are going to exit. 2009-10-07 18:12:11 +00:00
christos
40ab82d3c3 fix regression exit1: Don't exec the last command in a subshell if it has
trap[0] (trap EXIT) set. Fork instead to give the shell a chance to execute
the trap when it is done.
2009-10-06 20:05:10 +00:00
apb
db8f79df3d Make this slightly more portable; it has to run on arbitary host
platforms at build time.  Previousy, some shells were confused by
some of the "[ ... ]" tests.
2009-10-06 19:56:58 +00:00
joerg
f29cf7b612 Make indentation consistent. 2009-05-26 07:30:51 +00:00
drochner
0fa7059102 define YY_NO_INPUT where appropriate, from Kurt J. Lidl per PR misc/41160 2009-04-20 16:05:29 +00:00
wiz
7d6100a52d Bump date for previous. 2009-03-29 08:54:10 +00:00
mrg
fcc023545e - add new RLIMIT_AS (aka RLIMIT_VMEM) resource that limits the total
address space available to processes.  this limit exists in most other
modern unix variants, and like most of them, our defaults are unlimited.
remove the old mmap / rlimit.datasize hack.

- adds the VMCMD_STACK flag to all the stack-creation vmcmd callers.
it is currently unused, but was added a few years ago.

- add a pair of new process size values to kinfo_proc2{}. one is the
total size of the process memory map, and the other is the total size
adjusted for unused stack space (since most processes have a lot of
this...)

- patch sh, and csh to notice RLIMIT_AS.  (in some cases, the alias
RLIMIT_VMEM was already present and used if availble.)

- patch ps, top and systat to notice the new k_vm_vsize member of
kinfo_proc2{}.

- update irix, svr4, svr4_32, linux and osf1 emulations to support
this information.  (freebsd could be done, but that it's best left
as part of the full-update of compat/freebsd.)


this addresses PR 7897.  it also gives correct memory usage values,
which have never been entirely correct (since mmap), and have been
very incorrect since jemalloc() was enabled.

tested on i386 and sparc64, build tested on several other platforms.

thanks to many folks for feedback and testing but most espcially
chuq and yamt for critical suggestions that lead to this patch not
having a special ugliness i wasn't happy with anyway :-)
2009-03-29 01:02:48 +00:00
roy
9fa1d120a0 el_gets now sets el_len to -1 on error so we can distinguish
between a NULL string and an error.
This fixes sh from exiting with libedit now allowing EINTR to return.
We may need to expand this to an errno check in the future.
2009-03-10 21:21:11 +00:00
joerg
fdf2963413 Explicitly escape -- as it is not an argment to the Cm macro. 2009-03-10 15:14:28 +00:00
joerg
048b505ac7 Don't use .Xo/.Xc to workaround ancient macro argument limit. 2009-03-10 14:18:52 +00:00
joerg
997634fe14 Fix preamble to match order set out by mdoc(7). Discussed with wiz. 2009-03-09 19:24:26 +00:00
lukem
46b57afcf7 Default to WARNS=4 (except for rcp & ksh) 2009-02-14 08:31:13 +00:00
christos
8623c59aca Revert previous commit that fixes PR/36079 (shell misses exit trap), because
the fix causes $! to point to the wrong process in pipelines, which is worse.
2009-01-19 19:47:11 +00:00
lukem
c6144e484f fix -Wsign-compare issues 2009-01-18 00:24:29 +00:00
christos
3957d0cafc rlim_t will be unsigned as TOG mandates. 2008-12-28 19:53:37 +00:00
christos
97f12feac9 don't free other jobs when we are specifically using the wait built-in. 2008-12-21 17:16:11 +00:00
christos
271febebf6 use EXP_CASE only when trimming and unquoted. 2008-12-21 17:15:09 +00:00
christos
ae1cc09549 PR/36079: M. Levinson: Disable the optimization of not forking for the last
command in a subshell, otherwise we miss the exit trap.
2008-12-21 03:15:32 +00:00
christos
9ac082db6c PR/35055: Wada Keiji: wait did not keep the status of terminated jobs as
expected.
2008-12-21 00:19:59 +00:00
christos
26edf84a4b PR/36954: Roland Illig: don't eat backlash escapes in variable patterns.
Makes ${line%%\**} work.
2008-12-20 20:36:44 +00:00
yamt
8277de5576 document "EXIT" pseudo signal. 2008-12-11 04:34:45 +00:00
snj
976326ad53 Some spelling fixes from VaX#n8 in PR bin/23812. 2008-11-15 17:01:38 +00:00
christos
c8877ef31c and if you don't succeed twice, try again. 2008-11-08 00:14:05 +00:00
christos
440e6c6264 Try a different fix for PR/11317: Don't ignore errors in list(). 2008-11-07 15:18:11 +00:00
christos
2afd855bd9 Break PR/11317 again. The counting parentheses fix does not handle case
statements properly. Fixes PR/39873.
2008-11-07 15:08:43 +00:00
christos
9fd1d5af01 PR/11317: Hubert Feyrer: Recognize mismatched parentheses inside old style
command substitution.
2008-11-05 22:04:43 +00:00
christos
bc4eb9bdd7 show better quoting output for sh -x, from Aleksey Cheusov 2008-10-31 14:38:42 +00:00
apb
89799ead73 Pass SED=${TOOL_SED:Q} in the environment to scripts run during the build. 2008-10-25 22:23:55 +00:00
apb
125b7c8cbb In shell scripts run during the build, add a SED variable, defaulting
to "sed".  SED=${TOOL_SED:Q} should be passed in the environment to
override this.
2008-10-25 22:18:15 +00:00
apb
9577284633 Don't try to remove trailing newlines from shell variables via
constructs like ${var%$nl}.  Apparently this allows the Ubuntu Linux
/bin/sh (dash) to be used as a host shell during the build.
Patch from PR 39786 by Andy Shevchenko.
2008-10-23 20:21:57 +00:00
apb
cd5c0f944d In shell scripts invoked during a build, and in crunchgen, use ${AWK}
instead of plain "awk".  The Makefiles that invoke these scripts
or programs will pass AWK=${HOST_AWK:Q}.
2008-10-19 22:10:04 +00:00
apb
96230fab84 Use ${TOOL_AWK} instead of ${AWK} or plain "awk" in make commands.
Pass AWK=${TOOL_AWK:Q} to shell scripts that use awk.
2008-10-19 22:05:19 +00:00
dholland
7fb5a8c68e The field width passed for a %.*s printf format is supposed to be int, not
ptrdiff_t; on 64-bit platforms the latter will be too wide.
Adjust accordingly.
2008-10-16 17:58:29 +00:00
dholland
72c2627f1f Wrap declaration of a STATIC function that's only conditionally defined
in a suitable ifdef, so things still compile if STATIC is defined as
"static", which is for some reason not the default.
2008-10-16 15:36:23 +00:00
dholland
744c8edc4b Wrap declaration of a STATIC function that's only conditionally defined
in a suitable ifdef, so things still compile if STATIC is defined as
"static", which is for some reason not the default.

(In the long run STATIC should go away - it might have once been a
portability hack but now definitely serves no purpose.)
2008-10-16 15:31:05 +00:00
dholland
e54c6daca4 Remove unused global variables 2008-10-16 14:55:28 +00:00
dholland
0faa1734e3 Use "extern" properly for referencing globals defined in other modules.
Now builds cleanly with -warn-common.
2008-10-16 14:36:40 +00:00
dholland
30a1416240 output.c output.h: expose OUTPUT_ERR (flag for an exposed flags variable)
bltin.h: support ferror()
echo.c: use ferror() to fail on output write errors

Another piece of PR bin/39574.
2008-10-12 01:40:37 +00:00
christos
8c54d84110 Fix here documents that end abruptly without NL before EOF.
(Andy Shevchenko)
2008-08-23 10:05:52 +00:00
lukem
2fe2731d3f Remove the \n and tabs from the __COPYRIGHT() strings. 2008-07-20 00:52:39 +00:00
tron
9cae530b67 Revert revisions 1.91 and 1.92. The POSIX spec about the correct behaviour
is contradictory at best. And these changes seem to cause more problems
that they are worth.
2008-05-26 14:55:17 +00:00
tron
4d6f948f7a Fix two more cases of bad handling of "set -e":
- false && false
- false || false
2008-05-24 22:24:32 +00:00
tron
c2987416cd Fix another problem with "set -e": "! true" should terminate the shell. 2008-05-24 19:06:43 +00:00
tron
35fbf8dd7f Port revision 1.44 of "src/bin/sh/eval.c" from FreeBSD to fix PR bin/38584.
Reviewed by Michael van Elst.
2008-05-24 17:12:53 +00:00
martin
3028e483e4 Convert to new 2 clause license 2008-04-29 06:53:00 +00:00
christos
76560beef5 Detect unmatched quotes inside old style command substitution.
echo `"`
2008-04-25 17:32:31 +00:00
apb
cd12700971 If SHELL_BUILTIN is defined (as will be the case when building external
builtins such as the printf command), then hide a few declarations.

This allows the shell to build again, fixing a problem with
"error" being declared as a function here, and as a variable in
.../usr.bin/printf/printf.c.
2008-03-29 09:58:00 +00:00
apb
d6d9ccc8ad * define SHELL_BUILTIN, which other headers may use to hide some of their
symbols if appropriate.  For example, error.h will use it to hide
  declarations that should not be seen by external builtins such as printf.
* The shell's outfmt() function returns void, but the standard fprintf()
  function returns int.  Similarly for several other functions that are
  redefined via macros in bltin.h.  Add a _RETURN_INT macro to do the
  necessary conversion.
* Delete some declarations that appear in error.h.
* Add comments on some #else/#endif lines.
2008-03-29 09:55:40 +00:00
apb
074a931bf5 Remove trailing ';' in definitions of out1c and out2c macros. 2008-03-29 09:49:52 +00:00
dsl
01709217fc Generate ANSI functions.
Just indent the code by a single tab - no need to compare against the
C program generated version any more.
2008-02-27 21:56:14 +00:00
dsl
b63023e666 Change spaces to tabs for consistency with adjacent lines. 2008-02-27 21:55:07 +00:00
matt
4498b1fe25 Fix inconsistent definitions 2008-02-15 17:26:06 +00:00
joerg
f04ccd71b4 Set unique mode for the history, so that repeating a command doesn't
spam the history.
2008-02-13 12:57:16 +00:00
msaitoh
899c734b12 Conform to XCU Section 2.8.2 (Exit Status for Commands) 2008-01-21 06:43:03 +00:00
dogcow
90ee124aaf This should have been all on one line anyway - and hey, it fixes my build
issue.
2007-12-18 07:25:00 +00:00
perry
8b0f9554ff convert __attribute__s to applicable cdefs.h macros 2007-12-15 19:44:37 +00:00
lukem
bcf893f432 use __RCSID() 2007-12-12 22:55:42 +00:00
christos
2554aff24b PR/36531: Greg A. Woods: another very helpful DEBUG TRACE() call for execve()
failures in /bin/sh
2007-06-24 18:36:23 +00:00
christos
546dff6580 PR/36533: Greg A. Woods: minor doc fixes for sh(1) 2007-06-24 17:57:56 +00:00
dsl
8da3353686 Fix sh -c 'true && ! true | false; echo $?'
Add some more TRACE((...)) calls to aid such debugging.
Fixes PR bin/36435
Clearly no one tried this test when the changes of rev 1.31 and 1.44 were done!
2007-06-07 20:57:59 +00:00
apb
faafdc7e21 Document that shell arithmetic now uses intmax_t. Document that
variables in shell arithmetic don't need "$" signs.
2007-03-25 06:56:43 +00:00
apb
1a20cbd95e WARNS=4 2007-03-25 06:30:37 +00:00
apb
91ce988bec Make /bin/sh use intmax_t (instead of int) for arithmetic in $((...)). 2007-03-25 06:29:26 +00:00
rillig
9da5e43f4d Since interpreting ELF binaries as shell scripts is not very useful, and
since the current error message is less than helpful, improve it.
2007-02-15 12:02:59 +00:00
christos
30760cbdc7 PR/35410: Valeriy E. Ushakov: /bin/sh mishandles shell function definitions
with function names that are not plain words
1. remove the escape annotations from the function name.
2. check if the function has a valid name before storing it.
2007-01-13 18:58:26 +00:00