Patch-ID: bash41-003
[bash.git] / examples / scripts.noah / shcat.bash
blob5d9e96d084feeff18edc9c15468c938d0d31c4d5
1 # shcat.bash
2 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
3 # Created: 1992-07-17
4 # Last modified: 1993-09-29
5 # Public domain
7 # Conversion to bash v2 syntax done by Chet Ramey
9 # Commentary:
10 # Code:
12 #:docstring shcat:
13 # Usage: shcat {file1} {file2} {...}
15 # Like `cat', only this is all inline bash.
16 #:end docstring:
18 ###;;;autoload
19 function shcat ()
21 local IFS=""
22 local line
23 local file
24 local exitstat=0
26 if [ $# -eq 0 ]; then
27 while read -r line; do
28 echo "${line}"
29 done
30 return 0
31 else
32 for file in "$@" ; do
33 if [ -r "${file}" ]; then
34 while read -r line; do
35 echo "${line}"
36 done < "${file}"
37 else
38 # This will cause the error to be printed on stderr
39 < "${file}"
40 exitstat=1
42 done
43 return ${exitstat}
47 provide shcat
49 # shcat.bash ends here