2 * rl - command-line interface to read a line from the standard input
3 * (or another fd) using readline.
5 * usage: rl [-p prompt] [-u unit] [-d default] [-n nchars]
8 /* Copyright (C) 1987-2002 Free Software Foundation, Inc.
10 This file is part of the GNU Readline Library, a library for
11 reading lines of text with interactive input and history editing.
13 The GNU Readline Library is free software; you can redistribute it
14 and/or modify it under the terms of the GNU General Public License
15 as published by the Free Software Foundation; either version 2, or
16 (at your option) any later version.
18 The GNU Readline Library is distributed in the hope that it will be
19 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 The GNU General Public License is often shipped with GNU software, and
24 is generally kept in a file called COPYING or LICENSE. If you do not
25 have a copy of the license, write to the Free Software Foundation,
26 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
28 #if defined (HAVE_CONFIG_H)
33 #include <sys/types.h>
41 #if defined (READLINE_LIBRARY)
42 # include "posixstat.h"
43 # include "readline.h"
46 # include <sys/stat.h>
47 # include <readline/readline.h>
48 # include <readline/history.h>
54 #if !defined (strchr) && !defined (__STDC__)
55 extern char *strrchr();
58 static char *progname
;
66 rl_insert_text (deftext
);
67 deftext
= (char *)NULL
;
68 rl_startup_hook
= (rl_hook_func_t
*)NULL
;
76 fprintf (stderr
, "%s: usage: %s [-p prompt] [-u unit] [-d default] [-n nchars]\n",
90 progname
= strrchr(argv
[0], '/');
97 prompt
= "readline$ ";
101 while ((opt
= getopt(argc
, argv
, "p:u:d:n:")) != EOF
)
112 fprintf (stderr
, "%s: bad file descriptor `%s'\n", progname
, optarg
);
123 fprintf (stderr
, "%s: bad value for -n: `%s'\n", progname
, optarg
);
135 if (fstat (fd
, &sb
) < 0)
137 fprintf (stderr
, "%s: %d: bad file descriptor\n", progname
, fd
);
140 ifp
= fdopen (fd
, "r");
144 if (deftext
&& *deftext
)
145 rl_startup_hook
= set_deftext
;
148 rl_num_chars_to_read
= nch
;
150 temp
= readline (prompt
);
156 printf ("%s\n", temp
);
This page took 0.034236 seconds and 4 git commands to generate.