2 * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * @brief Concatenate files to stdout command
30 #include <linux/ctype.h>
38 * @param[in] cmdtp FIXME
39 * @param[in] argc Argument count from command line
40 * @param[in] argv List of input arguments
42 static int do_cat(struct command
*cmdtp
, int argc
, char *argv
[])
55 buf
= xmalloc(BUFSIZE
);
58 fd
= open(argv
[args
], O_RDONLY
);
61 printf("could not open %s: %s\n", argv
[args
], errno_str());
65 while((ret
= read(fd
, buf
, BUFSIZE
)) > 0) {
66 for(i
= 0; i
< ret
; i
++) {
67 if (isprint(buf
[i
]) || buf
[i
] == '\n' || buf
[i
] == '\t')
88 static const __maybe_unused
char cmd_cat_help
[] =
89 "Usage: cat [FILES]\n"
90 "Concatenate files on stdout. Currently only printable characters\n"
91 "and \\n and \\t are printed, but this should be optional\n";
93 BAREBOX_CMD_START(cat
)
95 .usage
= "concatenate file(s)",
96 BAREBOX_CMD_HELP(cmd_cat_help
)
100 * @page cat_command cat (concatenate)
102 * Usage is: cat \<file\> [\<file\> ...]
104 * Concatenate files to stdout. Currently only printable characters
105 * and \\n and \\t are printed, but this should be optional