2
* rlcat - cat(1) using readline
7
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
9
This file is part of the GNU Readline Library (Readline), a library for
10
reading lines of text with interactive input and history editing.
12
Readline is free software: you can redistribute it and/or modify
13
it under the terms of the GNU General Public License as published by
14
the Free Software Foundation, either version 3 of the License, or
15
(at your option) any later version.
17
Readline is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
GNU General Public License for more details.
22
You should have received a copy of the GNU General Public License
23
along with Readline. If not, see <http://www.gnu.org/licenses/>.
26
#if defined (HAVE_CONFIG_H)
34
#include <sys/types.h>
35
#include "posixstat.h"
52
#if defined (READLINE_LIBRARY)
53
# include "readline.h"
56
# include <readline/readline.h>
57
# include <readline/history.h>
65
static char *progname;
71
fprintf (stderr, "%s: usage: %s [-vEVN] [filename]\n", progname, progname);
80
int opt, Vflag, Nflag;
82
progname = strrchr(argv[0], '/');
88
vflag = Vflag = Nflag = 0;
89
while ((opt = getopt(argc, argv, "vEVN")) != EOF)
114
if (isatty(0) == 0 || argc || Nflag)
115
return stdcat(argc, argv);
117
rl_variable_bind ("editing-mode", Vflag ? "vi" : "emacs");
118
while (temp = readline (""))
122
printf ("%s\n", temp);
125
return (ferror (stdout));
135
while ((c = getc(fp)) != EOF)
137
if (vflag && isascii ((unsigned char)c) && isprint((unsigned char)c) == 0)
139
x = rl_untranslate_keyseq (c);
140
if (fputs (x, stdout) != 0)
143
else if (putchar (c) == EOF)
146
return (ferror (stdout));
159
return (fcopy(stdin));
161
for (i = 0, r = 1; i < argc; i++)
163
if (*argv[i] == '-' && argv[i][1] == 0)
167
fp = fopen (argv[i], "r");
170
fprintf (stderr, "%s: %s: cannot open: %s\n", progname, argv[i], strerror(errno));