Commit graph

114 commits

Author SHA1 Message Date
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
Cheer Xiao
8f045b9ec5 Fix spelling: s/circut/circuit/g 2013-01-24 19:20:06 +08:00
ridiculousfish
98a17f4046 Remove some functions which were rendered trivial by xiaq's changes. Make io_file_t take its path directly. Make io_buffer_t no longer use a shared_ptr for its data. 2013-01-19 10:59:43 -08:00
ridiculousfish
f850c021b7 Merge branch 'split-io' of git://github.com/xiaq/fish-shell into xiaq-split-io 2013-01-18 16:17:31 -08:00
Cheer Xiao
8600243683 Fix two clang warnings 2013-01-17 22:45:06 +08:00
Cheer Xiao
57ef5289fe Make is_input a member of io_pipe_t 2013-01-17 15:55:06 +08:00
Cheer Xiao
00b6431ad9 Split out io_pipe_t, let io_buffer_t inherit it 2013-01-17 15:55:05 +08:00
Cheer Xiao
e020ad0c06 Convert io_buffer_read to io_buffer_t::read 2013-01-17 15:55:05 +08:00
Cheer Xiao
9057801c4b Convert io_buffer_create to static io_buffer_t::create, make io_buffer_t constructor private 2013-01-17 15:55:05 +08:00
Cheer Xiao
0f443ef37b Convert io_buffer_destroy to ~io_buffer_t 2013-01-17 15:55:05 +08:00
Cheer Xiao
a20e0b9e2e Split out io_buffer_t, make input_redirect in exec() a raw pointer 2013-01-17 15:55:05 +08:00
Cheer Xiao
4b6bd7cae5 Split out io_file_t 2013-01-17 15:55:05 +08:00
Cheer Xiao
6f35792c74 Split out io_fd_t 2013-01-17 14:58:53 +08:00
ridiculousfish
9d6c4fa678 Make do_builtin_io multi-fork safe, moved it to postfork.cpp
Addresses https://github.com/fish-shell/fish-shell/issues/495
2013-01-11 15:09:53 -08:00
Cheer Xiao
b66233de78 Revert "Revert shared_ptr<io_data_t> changes until kinks are ironed out"
This reverts commit 77f1b1f0fe.
2013-01-11 14:18:10 -08:00
Cheer Xiao
ff49792f44 exec.cpp:exec: Don't remove block_io elements from j->io
When dulicate_prepend prepend copies of block_io elements to j->io, the
removing simply does nothing. Now that the same pointers are prepended to
j->io, don't remove them.
2013-01-11 14:18:10 -08:00
ridiculousfish
77f1b1f0fe Revert shared_ptr<io_data_t> changes until kinks are ironed out
https://github.com/fish-shell/fish-shell/pull/487

Revert "Merge branch 'oo-io' of git://github.com/xiaq/fish-shell into xiaq-oo-io"

This reverts commit f3c8f535a4, reversing
changes made to b02f6cf3bc.

Also reverts ac023f7588 and a79d3c680c
2013-01-04 02:05:30 -08:00
ridiculousfish
ac023f7588 Replace some shared_ptrs with const shared_ptr &. Don't use shared_ptr in postfork.cpp. Eliminate copy constructor in io_data_t. Simplify some other uses of shared_ptr<io_data_t> 2013-01-04 00:22:12 -08:00
Cheer Xiao
7f35f98d7d Use const shared_ptr<io_data_t>& instead of copying where appropriate. 2013-01-01 15:51:36 +08:00
Cheer Xiao
8b10b0a614 Convert all io_data_t copying to shared_ptr copying.
Copy constructor of io_data_t is removed.
2013-01-01 00:37:50 +08:00
Cheer Xiao
a9ada13a23 Use shared_ptr to manage io_data_t*. 2012-12-31 23:54:17 +08:00
Cheer Xiao
d6b5558cf2 Clean up initialization of pipe_{read,write} in exec() a bit. 2012-12-21 15:45:35 -08:00
ridiculousfish
50c04752f5 Make skip_fork a bool 2012-12-21 15:43:38 -08:00
ridiculousfish
2a91a7640c Make echo recognize -ne 2012-12-20 18:10:08 -08:00
ridiculousfish
ce15abd577 Rewrite str2wcstring to properly handle embedded nulls, and be simpler 2012-12-20 12:25:35 -08:00
ridiculousfish
d5af389d2e Simplify exec_subshell_internal 2012-12-19 16:40:10 -08:00
ridiculousfish
644607c29f Eliminate str2wcs 2012-12-19 13:31:06 -08:00
Cheer Xiao
09b1eee5d0 Random fixes to comments. 2012-12-16 12:23:24 +08:00
ridiculousfish
c5031c2b39 Output embedded null characters more often
https://github.com/fish-shell/fish-shell/issues/444
2012-12-12 15:44:01 -08:00