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-2009 Free Software Foundation, Inc.
10 This file is part of the GNU Readline Library (Readline), a library for
11 reading lines of text with interactive input and history editing.
13 Readline is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
18 Readline is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with Readline. If not, see <http://www.gnu.org/licenses/>.
27 #if defined (HAVE_CONFIG_H)
32 #include <sys/types.h>
40 #if defined (READLINE_LIBRARY)
41 # include "posixstat.h"
42 # include "readline.h"
45 # include <sys/stat.h>
46 # include <readline/readline.h>
47 # include <readline/history.h>
53 #if !defined (strchr) && !defined (__STDC__)
54 extern char *strrchr();
57 static char *progname
;
63 fprintf (stderr
, "ding!\n");
73 rl_insert_text (deftext
);
74 deftext
= (char *)NULL
;
75 rl_startup_hook
= (rl_hook_func_t
*)NULL
;
83 fprintf (stderr
, "%s: usage: %s [-p prompt] [-u unit] [-d default] [-n nchars]\n",
97 progname
= strrchr(argv
[0], '/');
104 prompt
= "readline$ ";
108 while ((opt
= getopt(argc
, argv
, "p:u:d:n:")) != EOF
)
119 fprintf (stderr
, "%s: bad file descriptor `%s'\n", progname
, optarg
);
130 fprintf (stderr
, "%s: bad value for -n: `%s'\n", progname
, optarg
);
142 if (fstat (fd
, &sb
) < 0)
144 fprintf (stderr
, "%s: %d: bad file descriptor\n", progname
, fd
);
147 ifp
= fdopen (fd
, "r");
151 if (deftext
&& *deftext
)
152 rl_startup_hook
= set_deftext
;
155 rl_num_chars_to_read
= nch
;
157 rl_event_hook
= event_hook
;
158 temp
= readline (prompt
);
164 printf ("%s\n", temp
);
This page took 0.033131 seconds and 4 git commands to generate.