Commit Graph

555 Commits

Author SHA1 Message Date
dsl ea2078818f TOG require that 'set +o' output the options in a form suitable for
restoring them - make it so.
2005-12-13 17:44:18 +00:00
dsl e60beff86b Don't change the name of the directory we are going to 'cd' to just because
we decide to remove a leading "./" when deciding whether to print the name.
Stops 'cd .//tmp' ending up the same as 'cd /tmp'.
Fixes PR/30735
2005-11-26 21:44:43 +00:00
christos 8d6ffce2ad PR/31548: Alexander Rigbo: $PWD not set when shell starts up, before pwd
or cd get executed.
2005-10-10 21:14:42 +00:00
christos c05266af8a fix setmode error handling. 2005-10-01 20:23:54 +00:00
tv 964f98e703 Make slightly more portable without extra conditionals needed:
- Use getpgrp() rather than getpgid(0).
  (getpgrp() is already used elsewhere in this same file.)

- Use waitpid(-1, a, b) rather than wait3(a, b, NULL).
2005-09-30 18:57:55 +00:00
wiz 2ea3362a10 In mdoc, use .Pp for new paragraphs, not .br. 2005-09-10 22:09:43 +00:00
dsl 8c772bc707 Don't apply CDPATH if the the first component of the target is "." or "..".
Fixes PR/30973 and applies the principle of least surprise.
Update documentation to match (including date).
(matches behaviour of pdksh - if not it's documentation)
2005-08-20 21:07:42 +00:00
wiz 980a2652ee Aspell, fix an Xref, drop trailing whitespace. 2005-07-15 22:33:48 +00:00
christos 0df4f0ca31 Only do certain actions when we are trully interactive, not just when we
are connected to a tty:
	1. enable editor
	2. print directory on directory change.
	3. print job messages
2005-07-15 17:49:43 +00:00
christos b0d51313b4 If we have a script and we are interactive, set interactive to 2. This
allows us to run scripts with -i without printing the prompt like the
other shells do.
2005-07-15 17:46:54 +00:00
christos e996b4625d Allow trap to work on ignored signals when the shell is interactive. 2005-07-15 17:23:48 +00:00
christos ab760d2891 make setsig() return sig_t 2005-07-11 02:37:31 +00:00
christos 3564ac65d4 Don't hard ignore signals that were ignored by our environment, because
when we try to set a trap on them it will not work. Also while I am here:
1. don't change the action status if the signal system call failed.
2. don't try to sigignore it if signal failed.
3. clear the signal mask in case our parent blocked it for us.
2005-07-11 02:37:05 +00:00
christos 6310b59691 sprinkle a little const, and now everything compiles with WARNS=3 2005-06-26 19:10:48 +00:00
christos b61c2197f1 Revert part of the previous commit. We cannot fix the problem by not waiting.
The problem is that the subshell code is not doing redirections properly.
2005-06-23 23:05:29 +00:00
christos 306d33d145 Don't wait for a background job in a subshell when we are set to EV_EXIT.
While I am here, call forkshell() explicitly FORK_FOO flags instead of
depending in FORK_FG == 0 and FORK_BG == 1.
2005-06-22 23:32:45 +00:00
lukem 5166671bc3 appease gcc -Wuninitialized 2005-06-01 15:41:19 +00:00
lukem 50cde64b47 Mark temp_path volatile so that it won't get clobbered after longjmp.
(Also appeases gcc -Wuninitialized.)
2005-06-01 15:38:32 +00:00
wiz 24bf3d8ac3 Whitespace and punctuation fixes. 2005-05-24 00:03:52 +00:00
christos c3b8cf7d21 Only add the function when we initialize. Restore the binding of tab to
ed-insert if tabcomplete is cleared.
2005-05-09 11:35:19 +00:00
dsl 82537bf8e8 If 'set -o tabcomplete' it set, then bind <tab> to the libedit filename
completion function.
Note that the libedit code will probably want fine-tuning!
While editing the man page, add a note that non-whitespace IFS chars are
terminators and can generate null arguments.
2005-05-07 19:52:17 +00:00
dsl 3acd9704cb A rather better fix for treating $((x)) as equivalent to $(($x)) provided
that $x has a numeric value - which is what posix/sus needs.
2005-03-21 22:37:09 +00:00
dsl a65ddf9664 Back out previous, amongst other things it breaks $((0x10)) 2005-03-21 20:10:29 +00:00
dsl b747d738fa Treat $((x)) as equivalent to $(($x)) - posix seems to require this now. 2005-03-20 21:39:11 +00:00
dsl aecb1ce456 Add 'continue' as body of empty loop. 2005-03-20 21:38:17 +00:00
dsl 328c436518 Check quoting before merging ifs regions.
sh -c 'set -- a; x="b c"; set -- "$@"$x'
now correctly gives $1=ab, $2=c
2005-03-19 16:38:27 +00:00
dsl 2078d2c0ca Don't merge ifs regions with different quoting requirements 2005-03-19 15:02:58 +00:00
dsl 4803d37f2b Fix the way the 'read' builtin processes IFS. In particular:
- IFS whitespace is now processes correctly,
- Trailing non-whitespace IFS characters are added to the last variable
  iff a subsequent variable would have been assigned a non-null string.
Now passes the 'read' tests in http://www.research.att.com/~gsf/public/ifs.sh
2005-03-19 14:22:50 +00:00
dsl 8693718ba1 Fix printing of invalid commandname after certain types of errors on builtins.
Fixes bug bin/29410 in head.
All of /bin/sh needs pulling up into 2.0
2005-03-02 20:57:31 +00:00
dsl f712e70aee expbackq() was incorrectly backing up a temporary buffer when removing \n
from the end of output of commands inside $(...) substitutions.
If the program output is n*128+1 bytes long (ending in a \n) then the code
checks buf[-1] for another \n - looking an uninitialised stack.
On a big-endian system an integer of value 10 will satisfy this (unlikely
on little endian) and can happen depending on the last code path to use
a lot of stack!
This caused the problem with newvers.sh on sparc64 after ', 2005' was
added to the date list.
Fixed PR/28852
2005-02-14 20:46:26 +00:00
perry 3fa24d7834 remove obsolete register declarations 2005-02-06 04:43:43 +00:00
christos 2a32d39ed6 PR/28940: David Laight: /bin/sh doesn't quote the output of trap. 2005-01-11 19:38:57 +00:00
christos 027df12dd8 Pass WARNS=3 2004-10-30 19:29:27 +00:00
enami 87aaf3d70d Fix a bug introduced by previous commit. It breaks export command
with multiple arguments if one of them are already set.  Fix PR#27155
and probably PR#27143.
2004-10-06 10:23:43 +00:00
dsl 5f9b910124 Save the length of each variable in the name table so that we can
compare the lengths and then use memcmp() in the search code.
Speeds up one of my scripts by a facter of 2.
Increase the size of the variable hash table.
Cuts down time for script to execute from 60 seconds to 10.
Move variable search into a new function to hide the implementation
from most of the code, new version is slightly smaller than old.
2004-10-02 12:16:53 +00:00
seb cf788c3115 Add new builtin `wordexp' to support wordexp(3).
From FreeBSD.
Provided in PR lib/26123.
Approved by kleink@.
2004-07-13 15:05:59 +00:00
christos 5dd9099216 PR/25699: David Laight: sh(1) hangs opening a named pipe as stdin for
background process
This happens because we vfork, and then open a named pipe with O_RDONLY
and block in the child. We avoid this, by opening the file with O_NONBLOCK,
and then reset it if we are vforked. XXX: this is an ugly fix.
2004-07-08 03:57:33 +00:00
mycroft 1ccdf5daeb Make "set -e" once again provide the behavior documented in the man page,
which was unnecessarily changed in revision 1.50 while fixing other bugs.
That is, exit the shell if the last command in a || or && compound statement
is not short-circuited, and exits with a false status.  I.e., the following
will cause the shell to exit:

  set -e
  false || false

While this is not the prescribed behavior in SUSv3, it is what our man page
documents, and it is what all of the following implementations do:

  NetBSD /bin/ksh (pdksh)
  bash
  zsh
  Solaris 9 /bin/sh
  Solaris 9 /usr/xpg4/bin/sh
  Solaris 9 /usr/bin/ksh
  Tru64 /bin/sh
  HP/UX 11 /bin/sh

The "standard" seems to be wrong in this instance.
2004-06-30 09:32:38 +00:00
dsl 60bb0d96f3 Fix treatment of ' inside a 'here document' with a quoted EOF marker.
Fixes a breakage from the previous version.
2004-06-27 10:27:57 +00:00
dsl c6cbc16d26 Correctly apply IFS to unquoted text in ${x-text}.
Fixes PR/26058 and the 'for i in ${x-a b c}; do ...' and ${x-'a b' c}.
I can't find a PR for the latter problem.
Regression test goind in shortly.
2004-06-26 22:09:49 +00:00
dsl 97e8f81436 Remove a broken optimistion that crept in earlier today. 2004-06-26 20:48:44 +00:00
dsl 8e940884ca Kill a diagnostic I accidentally left in. 2004-06-26 14:21:29 +00:00
dsl e4a2a056d2 No functional changes (intended).
Rename some variables, add some comments, and restructure a little.
In preparation for fixing "set ${x-a b c}" and friends.
2004-06-26 14:09:58 +00:00
dsl 39cf7788fc Use shell variables to get '(' and '\' inside shell substitution patterns.
Solves problems with different shells having differntly buggy parsers
(and the standard probably allowing random behaviour).
Should fix bin/25938
2004-06-15 23:09:54 +00:00
dsl c6e67e3bf2 Change '\0' to 0 so that the SVR4 'echo' doesn't convert it to a null byte.
Fixes bin/25938
2004-06-15 22:57:27 +00:00
christos cf19966782 Undo previous fix, breaks:
#!/bin/sh
echo ${1+"$@"}
./sh.new foo.sh a b c
a b c b c
I'll revisit this when I have some more time.
2004-06-09 12:17:36 +00:00
christos fc5d411571 "for i in ${x-a b c}; do echo $i; done" should print "a\nb\nc\n" not "a b c\n"
like other shells do. mark the expansion for ifs splitting. XXX: linux has a
very complicated fix for this. I wonder why.
2004-06-08 03:29:51 +00:00
christos 95a737969b don't include the printf builtin if we are SMALL; saves 10K. 2004-06-06 07:03:11 +00:00
hubertf c784286d1a Fix typo: and the -> and then 2004-06-03 19:54:37 +00:00
dsl 00a6315e86 Ensure that fd 0, 1 and 2 are not used for the local end of pipelines.
Fixes PR bin/25395
2004-04-30 06:27:59 +00:00