blob: 278b8e4479433efbd0aa050ccac0015b541f841b [file] [log] [blame]
Juan Cespedesac3db291998-04-25 14:31:58 +02001#if HAVE_CONFIG_H
2#include "config.h"
3#endif
4
Ian Wienand9a2ad352006-02-20 22:44:45 +01005#ifndef PACKAGE_VERSION
6# define PACKAGE_VERSION "0.3.32"
7#endif
8
Juan Cespedes5e01f651998-03-08 22:31:44 +01009#include <string.h>
10#include <stdlib.h>
11#include <unistd.h>
Juan Cespedes1b9cfd61999-08-30 19:34:50 +020012#include <fcntl.h>
Juan Cespedes5e01f651998-03-08 22:31:44 +010013#include <errno.h>
14#include <limits.h>
15
Juan Cespedesac3db291998-04-25 14:31:58 +020016#if HAVE_GETOPT_H
17#include <getopt.h>
18#endif
19
Juan Cespedes5e01f651998-03-08 22:31:44 +010020#include "ltrace.h"
21#include "options.h"
22#include "defs.h"
23
Steve Fink58c73a72006-07-17 23:18:35 +020024#ifndef SYSCONFDIR
25#define SYSCONFDIR "/etc"
26#endif
27
28#define SYSTEM_CONFIG_FILE SYSCONFDIR "/trace.conf"
29#define USER_CONFIG_FILE "~/.ltrace.conf"
30
Juan Cespedes1cd999a2001-07-03 00:46:04 +020031#define MAX_LIBRARY 30
32char *library[MAX_LIBRARY];
33int library_num = 0;
Juan Cespedesac3db291998-04-25 14:31:58 +020034static char *progname; /* Program name (`ltrace') */
Ian Wienand2d45b1a2006-02-20 22:48:07 +010035FILE *output;
Juan Cespedes5e01f651998-03-08 22:31:44 +010036int opt_a = DEFAULT_ACOLUMN; /* default alignment column for results */
Juan Cespedesd65efa32003-02-03 00:22:30 +010037int opt_c = 0; /* Count time, calls, and report a summary on program exit */
Juan Cespedes5e01f651998-03-08 22:31:44 +010038int opt_d = 0; /* debug */
39int opt_i = 0; /* instruction pointer */
40int opt_s = DEFAULT_STRLEN; /* default maximum # of bytes printed in strings */
41int opt_S = 0; /* display syscalls */
42int opt_L = 1; /* display library calls */
43int opt_f = 0; /* trace child processes as they are created */
Ian Wienand2d45b1a2006-02-20 22:48:07 +010044char *opt_u = NULL; /* username to run command as */
Juan Cespedesf666d191998-09-20 23:04:34 +020045int opt_r = 0; /* print relative timestamp */
Juan Cespedes5e0acdb1998-04-04 08:34:07 +020046int opt_t = 0; /* print absolute timestamp */
Juan Cespedesd914a202004-11-10 00:15:33 +010047#ifdef USE_DEMANGLE
Juan Cespedesac3db291998-04-25 14:31:58 +020048int opt_C = 0; /* Demangle low-level symbol names into user-level names */
49#endif
Juan Cespedes5b3ffdf2001-07-02 00:52:45 +020050int opt_n = 0; /* indent trace output according to program flow */
Juan Cespedesd65efa32003-02-03 00:22:30 +010051int opt_T = 0; /* show the time spent inside each call */
Juan Cespedes5e01f651998-03-08 22:31:44 +010052
53/* List of pids given to option -p: */
Ian Wienand2d45b1a2006-02-20 22:48:07 +010054struct opt_p_t *opt_p = NULL; /* attach to process with a given pid */
Juan Cespedes5e01f651998-03-08 22:31:44 +010055
Juan Cespedesac3db291998-04-25 14:31:58 +020056/* List of function names given to option -e: */
Ian Wienand2d45b1a2006-02-20 22:48:07 +010057struct opt_e_t *opt_e = NULL;
58int opt_e_enable = 1;
Juan Cespedesac3db291998-04-25 14:31:58 +020059
Ian Wienand9a2ad352006-02-20 22:44:45 +010060/* List of global function names given to -x: */
Paul Gilliam24e643a2006-03-13 18:43:13 +010061struct opt_x_t *opt_x = NULL;
Ian Wienand9a2ad352006-02-20 22:44:45 +010062
Steve Fink58c73a72006-07-17 23:18:35 +020063/* List of filenames give to option -F: */
64struct opt_F_t *opt_F = NULL; /* alternate configuration file(s) */
65
Paul Gilliambe320772006-04-24 22:06:23 +020066#ifdef PLT_REINITALISATION_BP
Ian Wienand9a2ad352006-02-20 22:44:45 +010067/* Set a break on the routine named here in order to re-initialize breakpoints
68 after all the PLTs have been initialzed */
Paul Gilliambe320772006-04-24 22:06:23 +020069char *PLTs_initialized_by_here = PLT_REINITALISATION_BP;
70#endif
Ian Wienand9a2ad352006-02-20 22:44:45 +010071
Ian Wienand2d45b1a2006-02-20 22:48:07 +010072static void usage(void)
73{
Juan Cespedesac3db291998-04-25 14:31:58 +020074#if !(HAVE_GETOPT || HAVE_GETOPT_LONG)
75 fprintf(stdout, "Usage: %s [command [arg ...]]\n"
Ian Wienand2d45b1a2006-02-20 22:48:07 +010076 "Trace library calls of a given program.\n\n", progname);
Juan Cespedesac3db291998-04-25 14:31:58 +020077#else
78 fprintf(stdout, "Usage: %s [option ...] [command [arg ...]]\n"
Ian Wienand2d45b1a2006-02-20 22:48:07 +010079 "Trace library calls of a given program.\n\n"
Juan Cespedesac3db291998-04-25 14:31:58 +020080# if HAVE_GETOPT_LONG
Ian Wienand2d45b1a2006-02-20 22:48:07 +010081 " -a, --align=COLUMN align return values in a secific column.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +020082# else
Ian Wienand2d45b1a2006-02-20 22:48:07 +010083 " -a COLUMN align return values in a secific column.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +020084# endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +010085 " -c count time and calls, and report a summary on exit.\n"
Juan Cespedesd914a202004-11-10 00:15:33 +010086# ifdef USE_DEMANGLE
Juan Cespedesac3db291998-04-25 14:31:58 +020087# if HAVE_GETOPT_LONG
Ian Wienand2d45b1a2006-02-20 22:48:07 +010088 " -C, --demangle decode low-level symbol names into user-level names.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +020089# else
Ian Wienand2d45b1a2006-02-20 22:48:07 +010090 " -C decode low-level symbol names into user-level names.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +020091# endif
92# endif
93# if HAVE_GETOPT_LONG
Ian Wienand2d45b1a2006-02-20 22:48:07 +010094 " -d, --debug print debugging info.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +020095# else
Ian Wienand2d45b1a2006-02-20 22:48:07 +010096 " -d print debugging info.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +020097# endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +010098 " -e expr modify which events to trace.\n"
99 " -f follow forks.\n"
Juan Cespedesd65efa32003-02-03 00:22:30 +0100100# if HAVE_GETOPT_LONG
Steve Fink58c73a72006-07-17 23:18:35 +0200101 " -F, --config=FILE load alternate configuration file\n"
102# else
103 " -F FILE load alternate configuration file\n"
104# endif
105 " (can be repeated).\n"
106# if HAVE_GETOPT_LONG
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100107 " -h, --help display this help and exit.\n"
Juan Cespedesd65efa32003-02-03 00:22:30 +0100108# else
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100109 " -h display this help and exit.\n"
Juan Cespedesd65efa32003-02-03 00:22:30 +0100110# endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100111 " -i print instruction pointer at time of library call.\n"
Juan Cespedesd65efa32003-02-03 00:22:30 +0100112# if HAVE_GETOPT_LONG
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100113 " -l, --library=FILE print library calls from this library only.\n"
Juan Cespedesd65efa32003-02-03 00:22:30 +0100114# else
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100115 " -l FILE print library calls from this library only.\n"
Juan Cespedesd65efa32003-02-03 00:22:30 +0100116# endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100117 " -L do NOT display library calls.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +0200118# if HAVE_GETOPT_LONG
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100119 " -n, --indent=NR indent output by NR spaces for each call level nesting.\n"
Juan Cespedes5b3ffdf2001-07-02 00:52:45 +0200120# else
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100121 " -n NR indent output by NR spaces for each call level nesting.\n"
Juan Cespedes5b3ffdf2001-07-02 00:52:45 +0200122# endif
123# if HAVE_GETOPT_LONG
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100124 " -o, --output=FILE write the trace output to that file.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +0200125# else
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100126 " -o FILE write the trace output to that file.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +0200127# endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100128 " -p PID attach to the process with the process ID pid.\n"
129 " -r print relative timestamps.\n"
130 " -s STRLEN specify the maximum string size to print.\n"
131 " -S display system calls.\n"
132 " -t, -tt, -ttt print absolute timestamps.\n"
133 " -T show the time spent inside each call.\n"
134 " -u USERNAME run command with the userid, groupid of username.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +0200135# if HAVE_GETOPT_LONG
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100136 " -V, --version output version information and exit.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +0200137# else
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100138 " -V output version information and exit.\n"
Juan Cespedesac3db291998-04-25 14:31:58 +0200139# endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100140 " -x NAME treat the global NAME like a library subroutine.\n"
Paul Gilliambe320772006-04-24 22:06:23 +0200141#ifdef PLT_REINITALISATION_BP
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100142 " -X NAME same as -x; and PLT's will be initialized by here.\n"
Paul Gilliambe320772006-04-24 22:06:23 +0200143#endif
144 "\nReport bugs to ltrace-devel@lists.alioth.debian.org\n",
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100145 progname);
Juan Cespedesac3db291998-04-25 14:31:58 +0200146#endif
Juan Cespedes5e01f651998-03-08 22:31:44 +0100147}
148
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100149static char *search_for_command(char *filename)
150{
Juan Cespedesf1bfe202002-03-27 00:22:23 +0100151 static char pathname[PATH_MAX];
Juan Cespedes5e01f651998-03-08 22:31:44 +0100152 char *path;
153 int m, n;
154
155 if (strchr(filename, '/')) {
156 return filename;
157 }
158 for (path = getenv("PATH"); path && *path; path += m) {
159 if (strchr(path, ':')) {
160 n = strchr(path, ':') - path;
161 m = n + 1;
162 } else {
163 m = n = strlen(path);
164 }
Juan Cespedesf1bfe202002-03-27 00:22:23 +0100165 if (n + strlen(filename) + 1 >= PATH_MAX) {
166 fprintf(stderr, "Error: filename too long\n");
167 exit(1);
168 }
169 strncpy(pathname, path, n);
Juan Cespedes5e01f651998-03-08 22:31:44 +0100170 if (n && pathname[n - 1] != '/') {
171 pathname[n++] = '/';
172 }
173 strcpy(pathname + n, filename);
174 if (!access(pathname, X_OK)) {
175 return pathname;
176 }
177 }
178 return filename;
179}
180
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100181char **process_options(int argc, char **argv)
182{
Juan Cespedesac3db291998-04-25 14:31:58 +0200183 progname = argv[0];
Juan Cespedes5e01f651998-03-08 22:31:44 +0100184 output = stderr;
185
Juan Cespedesac3db291998-04-25 14:31:58 +0200186#if HAVE_GETOPT || HAVE_GETOPT_LONG
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100187 while (1) {
Juan Cespedesac3db291998-04-25 14:31:58 +0200188 int c;
189#if HAVE_GETOPT_LONG
190 int option_index = 0;
191 static struct option long_options[] = {
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100192 {"align", 1, 0, 'a'},
Steve Fink58c73a72006-07-17 23:18:35 +0200193 {"config", 1, 0, 'F'},
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100194 {"debug", 0, 0, 'd'},
Juan Cespedesd914a202004-11-10 00:15:33 +0100195# ifdef USE_DEMANGLE
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100196 {"demangle", 0, 0, 'C'},
Juan Cespedes8e3e0821998-09-24 13:49:55 +0200197#endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100198 {"indent", 1, 0, 'n'},
199 {"help", 0, 0, 'h'},
200 {"library", 1, 0, 'l'},
201 {"output", 1, 0, 'o'},
202 {"version", 0, 0, 'V'},
203 {0, 0, 0, 0}
Juan Cespedesac3db291998-04-25 14:31:58 +0200204 };
Juan Cespedesd65efa32003-02-03 00:22:30 +0100205 c = getopt_long(argc, argv, "+cdfhiLrStTV"
Juan Cespedesd914a202004-11-10 00:15:33 +0100206# ifdef USE_DEMANGLE
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100207 "C"
Juan Cespedesac3db291998-04-25 14:31:58 +0200208# endif
Steve Fink58c73a72006-07-17 23:18:35 +0200209 "a:e:F:l:n:o:p:s:u:x:X:", long_options,
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100210 &option_index);
Juan Cespedesac3db291998-04-25 14:31:58 +0200211#else
Juan Cespedesd65efa32003-02-03 00:22:30 +0100212 c = getopt(argc, argv, "+cdfhiLrStTV"
Juan Cespedesd914a202004-11-10 00:15:33 +0100213# ifdef USE_DEMANGLE
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100214 "C"
Juan Cespedesac3db291998-04-25 14:31:58 +0200215# endif
Steve Fink58c73a72006-07-17 23:18:35 +0200216 "a:e:F:l:n:o:p:s:u:x:X:");
Juan Cespedesac3db291998-04-25 14:31:58 +0200217#endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100218 if (c == -1) {
Juan Cespedesac3db291998-04-25 14:31:58 +0200219 break;
Juan Cespedes5e01f651998-03-08 22:31:44 +0100220 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100221 switch (c) {
222 case 'a':
223 opt_a = atoi(optarg);
224 break;
225 case 'c':
226 opt_c++;
227 break;
Juan Cespedesd914a202004-11-10 00:15:33 +0100228#ifdef USE_DEMANGLE
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100229 case 'C':
230 opt_C++;
231 break;
Juan Cespedesac3db291998-04-25 14:31:58 +0200232#endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100233 case 'd':
234 opt_d++;
235 break;
236 case 'e':
237 {
238 char *str_e = strdup(optarg);
239 if (!str_e) {
240 perror("ltrace: strdup");
241 exit(1);
Ian Wienand9a2ad352006-02-20 22:44:45 +0100242 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100243 if (str_e[0] == '!') {
244 opt_e_enable = 0;
245 str_e++;
246 }
247 while (*str_e) {
248 struct opt_e_t *tmp;
249 char *str2 = strchr(str_e, ',');
250 if (str2) {
251 *str2 = '\0';
252 }
253 tmp = malloc(sizeof(struct opt_e_t));
Juan Cespedesd65efa32003-02-03 00:22:30 +0100254 if (!tmp) {
255 perror("ltrace: malloc");
256 exit(1);
257 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100258 tmp->name = str_e;
259 tmp->next = opt_e;
260 opt_e = tmp;
261 if (str2) {
262 str_e = str2 + 1;
263 } else {
264 break;
265 }
Ian Wienand9a2ad352006-02-20 22:44:45 +0100266 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100267 break;
268 }
269 case 'f':
270 opt_f = 1;
271 break;
Steve Fink58c73a72006-07-17 23:18:35 +0200272 case 'F':
273 {
274 struct opt_F_t *tmp = malloc(sizeof(struct opt_F_t));
275 if (!tmp) {
276 perror("ltrace: malloc");
277 exit(1);
278 }
279 tmp->filename = strdup(optarg);
280 tmp->next = opt_F;
281 opt_F = tmp;
282 break;
283 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100284 case 'h':
285 usage();
286 exit(0);
287 case 'i':
288 opt_i++;
289 break;
290 case 'l':
291 if (library_num == MAX_LIBRARY) {
292 fprintf(stderr,
293 "Too many libraries. Maximum is %i.\n",
294 MAX_LIBRARY);
295 exit(1);
296 }
297 library[library_num++] = optarg;
298 break;
299 case 'L':
300 opt_L = 0;
301 break;
302 case 'n':
303 opt_n = atoi(optarg);
304 break;
305 case 'o':
306 output = fopen(optarg, "w");
307 if (!output) {
308 fprintf(stderr,
309 "Can't open %s for output: %s\n",
310 optarg, strerror(errno));
311 exit(1);
312 }
313 setvbuf(output, (char *)NULL, _IOLBF, 0);
314 fcntl(fileno(output), F_SETFD, FD_CLOEXEC);
315 break;
316 case 'p':
317 {
318 struct opt_p_t *tmp =
319 malloc(sizeof(struct opt_p_t));
320 if (!tmp) {
321 perror("ltrace: malloc");
322 exit(1);
323 }
324 tmp->pid = atoi(optarg);
325 tmp->next = opt_p;
326 opt_p = tmp;
327 break;
328 }
329 case 'r':
330 opt_r++;
331 break;
332 case 's':
333 opt_s = atoi(optarg);
334 break;
335 case 'S':
336 opt_S = 1;
337 break;
338 case 't':
339 opt_t++;
340 break;
341 case 'T':
342 opt_T++;
343 break;
344 case 'u':
345 opt_u = optarg;
346 break;
347 case 'V':
348 printf("ltrace version " PACKAGE_VERSION ".\n"
349 "Copyright (C) 1997-2006 Juan Cespedes <cespedes@debian.org>.\n"
350 "This is free software; see the GNU General Public Licence\n"
351 "version 2 or later for copying conditions. There is NO warranty.\n");
352 exit(0);
353 case 'X':
Paul Gilliambe320772006-04-24 22:06:23 +0200354#ifdef PLT_REINITALISATION_BP
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100355 PLTs_initialized_by_here = optarg;
Paul Gilliambe320772006-04-24 22:06:23 +0200356#else
357 fprintf(stderr, "WANRING: \"-X\" not used for this "
358 "architecture: assuming you meant \"-x\"\n");
359#endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100360 /* Fall Thru */
Juan Cespedesac3db291998-04-25 14:31:58 +0200361
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100362 case 'x':
363 {
Paul Gilliam24e643a2006-03-13 18:43:13 +0100364 struct opt_x_t *p = opt_x;
Ian Wienand9a2ad352006-02-20 22:44:45 +0100365
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100366 /* First, check for duplicate. */
367 while (p && strcmp(p->name, optarg)) {
368 p = p->next;
369 }
370 if (p) {
Ian Wienand9a2ad352006-02-20 22:44:45 +0100371 break;
372 }
373
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100374 /* If not duplicate, add to list. */
Paul Gilliam24e643a2006-03-13 18:43:13 +0100375 p = malloc(sizeof(struct opt_x_t));
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100376 if (!p) {
377 perror("ltrace: malloc");
378 exit(1);
379 }
380 p->name = optarg;
Paul Gilliam24e643a2006-03-13 18:43:13 +0100381 p->found = 0;
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100382 p->next = opt_x;
383 opt_x = p;
384 break;
385 }
Ian Wienand9a2ad352006-02-20 22:44:45 +0100386
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100387 default:
Juan Cespedesac3db291998-04-25 14:31:58 +0200388#if HAVE_GETOPT_LONG
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100389 fprintf(stderr,
390 "Try `%s --help' for more information\n",
391 progname);
Juan Cespedesac3db291998-04-25 14:31:58 +0200392#else
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100393 fprintf(stderr, "Try `%s -h' for more information\n",
394 progname);
Juan Cespedesac3db291998-04-25 14:31:58 +0200395#endif
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100396 exit(1);
Juan Cespedes5e01f651998-03-08 22:31:44 +0100397 }
398 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100399 argc -= optind;
400 argv += optind;
Juan Cespedesac3db291998-04-25 14:31:58 +0200401#endif
Juan Cespedes5e01f651998-03-08 22:31:44 +0100402
Steve Fink58c73a72006-07-17 23:18:35 +0200403 if (!opt_F) {
404 opt_F = malloc(sizeof(struct opt_F_t));
405 opt_F->next = malloc(sizeof(struct opt_F_t));
406 opt_F->next->next = NULL;
407 opt_F->filename = USER_CONFIG_FILE;
408 opt_F->next->filename = SYSTEM_CONFIG_FILE;
409 }
410 /* Reverse the config file list since it was built by
411 * prepending, and it would make more sense to process the
412 * files in the order they were given. Probably it would make
413 * more sense to keep a tail pointer instead? */
414 {
415 struct opt_F_t *egg = NULL;
416 struct opt_F_t *chicken;
417 while (opt_F) {
418 chicken = opt_F->next;
419 opt_F->next = egg;
420 egg = opt_F;
421 opt_F = chicken;
422 }
423 opt_F = egg;
424 }
425
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100426 if (!opt_p && argc < 1) {
Juan Cespedesac3db291998-04-25 14:31:58 +0200427 fprintf(stderr, "%s: too few arguments\n", progname);
Juan Cespedes5c3fe062004-06-14 18:08:37 +0200428 usage();
Juan Cespedes5e01f651998-03-08 22:31:44 +0100429 exit(1);
430 }
Juan Cespedesf666d191998-09-20 23:04:34 +0200431 if (opt_r && opt_t) {
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100432 fprintf(stderr, "%s: Incompatible options -r and -t\n",
433 progname);
Juan Cespedesf666d191998-09-20 23:04:34 +0200434 exit(1);
435 }
Ian Wienand2d45b1a2006-02-20 22:48:07 +0100436 if (argc > 0) {
Juan Cespedesac3db291998-04-25 14:31:58 +0200437 command = search_for_command(argv[0]);
Juan Cespedes1fe93d51998-03-13 00:29:21 +0100438 }
Juan Cespedesac3db291998-04-25 14:31:58 +0200439 return &argv[0];
Juan Cespedes5e01f651998-03-08 22:31:44 +0100440}