Debian Codegraph @

upperconv.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # upperconv.sh
3 # Converts a specified input file to uppercase.
4
5 E_FILE_ACCESS=70
6 E_WRONG_ARGS=71
7
8 if [scip-shell system . . `[`. ! -r "$1" ] # Is specified input file readable?
9 then
10 echoscip-shell system . . echo. "Can't read from input file!"
11 echoscip-shell system . . echo. "Usage: $0 input-file output-file"
12 exit $E_FILE_ACCESS
13 fi # Will exit with same error
14 #+ even if input file ($1) not specified (why?).
15
16 if [scip-shell system . . `[`. -z "$2" ]
17 then
18 echoscip-shell system . . echo. "Need to specify output file."
19 echoscip-shell system . . echo. "Usage: $0 input-file output-file"
20 exit $E_WRONG_ARGS
21 fi
22
23
24 exec 4<&0
25 exec < $1 # Will read from input file.
26
27 exec 7>&1
28 exec > $2 # Will write to output file.
29 # Assumes output file writable (add check?).
30
31 # -----------------------------------------------
32 catscip-shell system . . cat. - | trscip-shell system . . tr. a-z A-Z # Uppercase conversion.
33 # ^^^^^ # Reads from stdin.
34 # ^^^^^^^^^^ # Writes to stdout.
35 # However, both stdin and stdout were redirected.
36 # Note that the 'cat' can be omitted.
37 # -----------------------------------------------
38
39 exec 1>&7 7>&- # Restore stout.
40 exec 0<&4 4<&- # Restore stdin.
41
42 # After restoration, the following line prints to stdout as expected.
43 echoscip-shell system . . echo. "File \"$1\" written to \"$2\" as uppercase conversion."
44
45 exit 0