]>
git.ipfire.org Git - thirdparty/bash.git/blob - lib/readline/examples/rl.c
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]
9 * Remove the next line if you're compiling this against an installed
12 #define READLINE_LIBRARY
14 #if defined (HAVE_CONFIG_H)
19 #include <sys/types.h>
20 #include "posixstat.h"
27 extern char *strrchr();
29 static char *progname
;
37 rl_insert_text (deftext
);
38 deftext
= (char *)NULL
;
39 rl_startup_hook
= (Function
*)NULL
;
45 fprintf (stderr
, "%s: usage: %s [-p prompt] [-u unit] [-d default]\n",
58 progname
= strrchr(argv
[0], '/');
65 prompt
= "readline$ ";
69 while ((opt
= getopt(argc
, argv
, "p:u:d:")) != EOF
)
80 fprintf (stderr
, "%s: bad file descriptor `%s'\n", progname
, optarg
);
95 if (fstat (fd
, &sb
) < 0)
97 fprintf (stderr
, "%s: %d: bad file descriptor\n", progname
, fd
);
100 ifp
= fdopen (fd
, "r");
104 if (deftext
&& *deftext
)
105 rl_startup_hook
= set_deftext
;
107 temp
= readline (prompt
);