2 * rlcat - cat(1) using readline
7 /* Copyright (C) 1987-2002 Free Software Foundation, Inc.
9 This file is part of the GNU Readline Library, a library for
10 reading lines of text with interactive input and history editing.
12 The GNU Readline Library is free software; you can redistribute it
13 and/or modify it under the terms of the GNU General Public License
14 as published by the Free Software Foundation; either version 2, or
15 (at your option) any later version.
17 The GNU Readline Library is distributed in the hope that it will be
18 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
19 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 The GNU General Public License is often shipped with GNU software, and
23 is generally kept in a file called COPYING or LICENSE. If you do not
24 have a copy of the license, write to the Free Software Foundation,
25 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
27 #if defined (HAVE_CONFIG_H)
35 #include <sys/types.h>
36 #include "posixstat.h"
53 #if defined (READLINE_LIBRARY)
54 # include "readline.h"
57 # include <readline/readline.h>
58 # include <readline/history.h>
66 static char *progname
;
72 fprintf (stderr
, "%s: usage: %s [-vEVN] [filename]\n", progname
, progname
);
81 int opt
, Vflag
, Nflag
;
83 progname
= strrchr(argv
[0], '/');
89 vflag
= Vflag
= Nflag
= 0;
90 while ((opt
= getopt(argc
, argv
, "vEVN")) != EOF
)
115 if (isatty(0) == 0 || argc
|| Nflag
)
116 return stdcat(argc
, argv
);
118 rl_variable_bind ("editing-mode", Vflag
? "vi" : "emacs");
119 while (temp
= readline (""))
123 printf ("%s\n", temp
);
126 return (ferror (stdout
));
136 while ((c
= getc(fp
)) != EOF
)
138 if (vflag
&& isascii ((unsigned char)c
) && isprint((unsigned char)c
) == 0)
140 x
= rl_untranslate_keyseq (c
);
141 if (fputs (x
, stdout
) != 0)
144 else if (putchar (c
) == EOF
)
147 return (ferror (stdout
));
160 return (fcopy(stdin
));
162 for (i
= 0, r
= 1; i
< argc
; i
++)
164 if (*argv
[i
] == '-' && argv
[i
][1] == 0)
168 fp
= fopen (argv
[i
], "r");
171 fprintf (stderr
, "%s: %s: cannot open: %s\n", progname
, argv
[i
], strerror(errno
));
This page took 0.033949 seconds and 4 git commands to generate.