MCPcopy Create free account
hub / github.com/coreutils/coreutils / main

Function main

src/tee.c:128–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128int
129main (int argc, char **argv)
130{
131 initialize_main (&argc, &argv);
132 set_program_name (argv[0]);
133 setlocale (LC_ALL, "");
134 bindtextdomain (PACKAGE, LOCALEDIR);
135 textdomain (PACKAGE);
136
137 atexit (close_stdout);
138
139 int optc;
140 while ((optc = getopt_long (argc, argv, "aip", long_options, NULL)) != -1)
141 {
142 switch (optc)
143 {
144 case 'a':
145 append = true;
146 break;
147
148 case 'i':
149 ignore_interrupts = true;
150 break;
151
152 case 'p':
153 if (optarg)
154 output_error = XARGMATCH ("--output-error", optarg,
155 output_error_args, output_error_types);
156 else
157 output_error = output_error_warn_nopipe;
158 break;
159
160 case_GETOPT_HELP_CHAR;
161
162 case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
163
164 default:
165 usage (EXIT_FAILURE);
166 }
167 }
168
169 if (ignore_interrupts)
170 signal (SIGINT, SIG_IGN);
171
172 if (output_error != output_error_sigpipe)
173 signal (SIGPIPE, SIG_IGN);
174
175 /* Whether to detect and close a broken pipe output.
176 There is no need if the input is always ready for reading. */
177 bool pipe_check = ((output_error == output_error_warn_nopipe
178 || output_error == output_error_exit_nopipe)
179 && iopoll_input_ok (STDIN_FILENO));
180
181 /* Do *not* warn if tee is given no file arguments.
182 POSIX requires that it work when given no arguments. */
183
184 bool ok = tee_files (argc - optind, &argv[optind], pipe_check);
185 if (close (STDIN_FILENO) != 0)

Callers

nothing calls this directly

Calls 3

iopoll_input_okFunction · 0.85
tee_filesFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected