Commit Graph

142 Commits

Author SHA1 Message Date
ridiculousfish
906d235601 Add more expository comments to eval, and remove a useless parameter 2015-01-07 14:56:41 -08:00
ridiculousfish
fa854d7a01 Eliminate wcsv2strv 2014-10-30 18:52:37 -07:00
ridiculousfish
98091faeaf Add an assertion to reflect unreachable code 2014-10-19 18:00:49 -07:00
Kevin Ballard
cfc06203e7 Add new functions flag -V/--inherit-variable
--inherit-variable takes a variable name and snapshots its current
value. When the function is executed, it will have a local variable with
this value already defined. Printing the function source will include
synthesized `set -l` lines for the values.

This is primarily useful for functions that are created on the fly, such
as in `psub`.
2014-10-02 18:41:39 -07:00
Kevin Ballard
3616dd5889 Base status -b off the parser execution stack
Instead of globally marking the state as "in block" when evaluating
blocks/functions, update the "in block" status when pushing/popping
blocks on the parser stack.

Fixes #1729.

On a side note, `status -b` is actually pretty useless, because it
always returns 0 inside of a function (even without this patch).
2014-09-30 20:58:45 -07:00
Kevin Ballard
489fb7ec3f Expunge INTERNAL_BLOCK from the codebase
It's a relic of the old parser, and isn't used anymore.
2014-09-30 17:20:46 -07:00
Kevin Ballard
51527612d3 Don't leave is_block in bad state after bad redirection
Fixes #1728.
2014-09-30 17:06:56 -07:00
ridiculousfish
e5aa06991e Remove INTERNAL_BUFFER, which was only used by fish_pager 2014-09-22 10:16:16 -07:00
Kevin Ballard
940f264ee6 Decrement SHLVL when running exec
`exec` removes fish from the shell "stack", so SHLVL needs to be
decremented to match. This means `exec fish` will result in the same
SHLVL in the new fish instance.

Also tweak the SHLVL logic to interpret an environment SHLVL of "3foo"
as garbage instead of as the value "3".

Fixes #1693.
2014-09-19 17:38:54 -07:00
Kevin Ballard
7fce9e2411 Trim trailing newline on cmdsubst when IFS=''
When $IFS is empty, command substitution no longer splits on newlines.
However we still want to trim off a single trailing newline, as most
commands will emit a trailing newline and it makes it harder to work
with their output.
2014-08-29 12:48:45 -07:00
Kevin Ballard
d63db59ade Clean up the IFS handling in command substitution
Remove the useless ASCII test of the first byte of IFS. We don't split
on the first character, we only use a non-empty IFS as a signal to split
on newlines.
2014-08-21 20:57:23 -07:00
ridiculousfish
98297e5234 Teach while loops to not hang forever with no-execute
Fixes #1543
2014-07-11 11:28:10 -07:00
ridiculousfish
1ce30deec3 Remove the close_old field from io_fd_t, which is never actually
respected - a bug dating back to fish 1.x! The fd that would be closed
is actually closed in io_cleanup_fds().
2014-04-16 15:31:28 -07:00
ridiculousfish
7a75e7341b Eliminate the parser_use_ast switch, which does nothing, and
exec_no_exec, which also does nothing in the new parser
2014-04-14 11:12:40 -07:00
ridiculousfish
ec6dee8bd1 Minor cleanup of redirection functions 2014-04-11 09:50:12 -07:00
ridiculousfish
3cfdc6d126 Fix line number reporting in new parser 2014-03-20 21:32:02 -07:00
ridiculousfish
73c2846d64 Remove support for input IO_BUFFERs, which were only used by fish_pager 2014-03-15 19:49:55 -07:00
ridiculousfish
be33d3f2a4 Revert "Merge pull request #1317 from pullreq/cpp"
This reverts commit 74135c0600, reversing
changes made to 6d749789ce.

See discussion in #1317
2014-02-28 02:16:48 -08:00
Geoff Nixon
18dd6f58e3 Fixes .c -> .cpp in comments. For doxygen. 2014-02-27 06:23:40 -08:00
ridiculousfish
53814983ff Update style and formatting to conform to fish style guide. 2014-01-15 01:40:40 -08:00
ridiculousfish
1863be7be4 Fix some warnings 2014-01-01 15:49:41 -08:00
ridiculousfish
a9787b769f Support for implicit cd, no-exec, and the exit builtin. All tests now
pass (!). Error reporting still unsteady.
2013-12-29 16:23:26 -08:00
ridiculousfish
0f9de11a67 Fix issues related to redirections and block level IO with new parser 2013-12-28 16:18:38 -08:00
ridiculousfish
715823a666 Bringup of function definitions, switch statements with new parser 2013-12-27 03:58:42 -08:00
ridiculousfish
6ce4b344e4 Hook up for statements, if statements, and function definition in new
parser
2013-12-27 01:38:43 -08:00
ridiculousfish
e38217683c Refactor block_t storage in parser_t from a linked list to a vector 2013-12-20 17:41:21 -08:00
Konrad Borowski
ac7a461070 Cast size_t to unsigned long.
printf expects unsigned long (%lu) argument, however, size_t doesn't
have to be declared as such. As %zu is C99 (but not C++), it shouldn't
be used directly. Instead, I have to cast value to the correct type.
2013-11-25 15:56:08 +01:00
ridiculousfish
cf766b55cc Fix formatting 2013-10-26 15:27:39 -07:00
ridiculousfish
a8af974895 Fix a C++11 compile error with clang.
https://github.com/mxcl/homebrew/pull/22016#issuecomment-23222977
2013-08-25 00:45:43 -07:00
ridiculousfish
7b6780f712 Put read pipe last so that eval works again. Addresses https://github.com/fish-shell/fish-shell/issues/966 2013-08-21 13:46:11 -07:00
ridiculousfish
ee113a5632 Replace some #warnings with a comment explaining why the code is OK 2013-08-19 18:17:01 -07:00
ridiculousfish
4899086b3c Big fat refactoring of how redirections work. In fish 1.x and 2.0.0, the redirections for a process were flattened into a big list associated with the job, so there was no way to tell which redirections applied to each process. Each process therefore got all the redirections associated with the job. See https://github.com/fish-shell/fish-shell/issues/877 for how this could manifest.
With this change, jobs only track their block-level redirections. Process level redirections are correctly associated with the process, and at exec time we stitch them together (block, pipe, and process redirects).

This fixes the weird issues where redirects bleed across pipelines (like #877), and also allows us to play with the order in which redirections are applied, since the final list is constructed right before it's needed.  This lets us put pipes after block level redirections but before process level redirections, so that a 2>&1-type redirection gets picked up after the pipe, i.e. it should fix https://github.com/fish-shell/fish-shell/issues/110

This is a significant change. The tests all pass. Cross your fingers.
2013-08-19 18:06:24 -07:00
ridiculousfish
e849beabba Initial work towards various IO cleanups with an eye to fixing https://github.com/fish-shell/fish-shell/issues/110 2013-08-19 18:06:24 -07:00
ridiculousfish
640118e781 Cleanup of code that decides whether or not to fork. Fix for issue where stderr may be output twice. 2013-06-16 23:26:43 -07:00
ridiculousfish
c6ec2645dc Fix for incorrect use of shared ptr references 2013-06-16 12:51:49 -07:00
ridiculousfish
2da81b0ae7 Formatting and style updates 2013-05-05 02:33:17 -07:00
ridiculousfish
437b4397b9 Mark stdin as nonblocking if we get EWOULDBLOCK, and before handing it off to child processes when either starting them or moving them to the foreground.
https://github.com/fish-shell/fish-shell/issues/176
2013-04-07 12:40:08 -07:00
ridiculousfish
b04e874e43 Teach fish how to push and pop blocks even in the face of no_exec. All tests finally pass.
https://github.com/fish-shell/fish-shell/issues/624
2013-03-25 16:06:12 -07:00
ridiculousfish
94b1d58cc2 Additional changes related to https://github.com/fish-shell/fish-shell/pull/592 2013-02-28 10:25:32 -08:00
ridiculousfish
a8e92639af Cleanup and simplify null_terminated_array_t and its clients 2013-02-22 16:22:56 -08:00
ridiculousfish
9f8fe3d5e3 Hopeful fix to avoid forking for certain builtins like echo when they have an input redirection only 2013-02-22 13:20:27 -08:00
ridiculousfish
c9b4163e23 Fix a crash when redirecting a nonexistent file to a function
https://github.com/fish-shell/fish-shell/pull/574
2013-02-20 12:25:01 -08:00
ridiculousfish
4416753df0 More cleanup based on static analysis
https://github.com/fish-shell/fish-shell/issues/575
2013-02-16 02:38:13 -08:00
Cheer Xiao
be23c0755e exec(): Fix a stupid crash. Remove commented debug code that became invalidated. 2013-02-11 22:05:48 -08:00
Cheer Xiao
db55176212 In exec(), only add and remove pipe_{read,write} when necessary 2013-02-11 22:05:48 -08:00
Cheer Xiao
3f9706a7f3 Make io_data_t::fd const
In exec(), pipe_{write,read} no longer get reused.
2013-02-11 22:05:47 -08:00
Jan Kanis
51a955c75c remove __warn_unused attribute from exec_subshell 2013-02-06 01:11:46 +01:00
ridiculousfish
ad8d68dd43 Make subcommands modify $status, and make builtin_set not modify status unless it fails
https://github.com/fish-shell/fish-shell/issues/547
https://github.com/fish-shell/fish-shell/issues/214
2013-01-31 15:57:08 -08:00
ridiculousfish
3f8baeba20 Attempt to further improve fish's handling when it runs out of fds, and plug some fd leaks 2013-01-30 03:08:06 -08:00
ridiculousfish
1879dc4b59 Initial set of changes working to make fish robust against running out of file descriptors 2013-01-30 02:22:38 -08:00