Commit Graph

577 Commits

Author SHA1 Message Date
christos a54fe38a0d fix a volatile variable; from Anon Ymous 2006-12-18 00:37:33 +00:00
wiz 5c056f6785 s/apparant/apparent/, from Zafer. 2006-11-24 22:54:47 +00:00
christos 272937609b sprinkle volatile. 2006-10-16 00:36:19 +00:00
christos ab28bede4c Prefix "Syntax Error" with the program name, if the command name is not
available. At least this way we get an idea of what program gives us the
message.
2006-10-04 15:00:38 +00:00
dsl 1719403bf2 Fix typo, update date.
Fixes PR/34472
2006-09-04 20:30:36 +00:00
dsl c58b829dda Set the 'not a parameter' flag when we skip initial whitespace.
Otherwise:
    ./sh -c 'x=" "; for a in $x; do echo a${a}a; done'
is processed as a single empty parameter (instead of no parameters).
Should fix the breakage I introdiced in rev 1.75 and PR/34256 and PR/34254
2006-08-22 18:11:42 +00:00
dsl 413b7762c2 Rework the code changes from revisions 1.69, 1.70 and 1.74 so that the code
behaves correctly.
As far as I can tell, "x$@y" now expands correctly, as does IFS=:; set -$IFS.
Fixes PR/33472 (again) and PR/33956
2006-08-21 21:30:14 +00:00
christos a8b3562160 PR/33775: YAMAMOTO Takashi: /bin/sh doesn't accept "(" before case patterns 2006-06-20 15:57:44 +00:00
dsl 0e765f005a When expanding "$@" add a \0 byte after the last argument (as well as all
the earlier ones) so that a separator is added before it when it is empty.
This wasn't needed before a recent change that chenged the behaviour of
trailing whitespace IFS characters.
Fixed PR/33472
2006-05-20 13:57:27 +00:00
christos e80f354dab Coverity CID 3384: Don't close -1. 2006-05-13 19:47:22 +00:00
mrg 084c052803 quell GCC 4.1 uninitialised variable warnings.
XXX: we should audit the tree for which old ones are no longer needed
after getting the older compilers out of the tree..
2006-05-10 21:53:14 +00:00
simonb 15dc85722d Make the change for bin/31548 to set $PWD on shell startup non-fatal if
the current directory doesn't exist.
2006-05-04 11:16:53 +00:00
snj a640fe8c43 It's "its." 2006-04-24 19:00:29 +00:00
snj bf5ceaae16 It's "its." 2006-04-24 18:00:53 +00:00
christos da09d1a838 PR/33281: Martin J. Laubach: Prevent core-dump on "echo abc | { }". bash
prints and error and ksh prints nothing. We go the ksh way.
2006-04-18 14:44:05 +00:00
christos 3e359756c9 Coverity CID 620: Remove dead code. 2006-03-18 05:25:56 +00:00
christos f6828859fa Coverity CID 890: Possible NULL pointer deref. 2006-03-18 05:23:08 +00:00
christos 169a269417 Coverity CID 1329: Possible NULL deref. 2006-03-18 05:17:36 +00:00
christos df8cbb182e Coverity CID 2479: Clarify confusion about uninitialized variable in the
presence of setjmp/vfork.
2006-03-17 17:20:47 +00:00
rumble 2174dda221 Handle asprintf failing to allocate. 2006-03-17 14:43:11 +00:00
aymeric d5d0c11532 Make the -s flag of fc work correctly. Ensure that only one command is specified
and ensure that we break out of the loop after executing it.
With the previous code, because the re-executed command was added to the
history, it would think that it still had to execute it, leading to an infinite
loop.

The last thing which differs from ksh is that we get the "fc -s " command into
the history, but this is actually rather a feature in my humble opinion.

To test:
$ echo hello
$ fc -s ec
<infinite loop or correct behaviour>
2006-03-06 00:09:22 +00:00
garbled 6ac601d8c4 Add error printing for ENAMETOOLONG. Partially addresses PR bin/13850 .
The actual bug mentioned in that PR no longer exists, but it does cause:
~~~~~: error 63
Which this fix cleans up.
2006-01-02 19:10:33 +00:00
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