blob: 49a04a4fda02a5b38cab112afe0d974cdf039415 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/bin/sh
# Stand-in for z/OS cp(1) with //'DSN' and //'DSN(MEMBER)' names; members
# are fixed 80-byte records, so text written to them comes back padded.
store=${ZOS_STUB_STORE:-${TMPDIR:-/tmp}/zos-stub-store}
[ "$1" = -T ] && shift
map() {
case $1 in
"//'"*) n=${1#"//'"}; n=${n%"'"}
case $n in *\(*\)) d=${n%%(*}; m=${n#*(}; m=${m%)}; [ -d "$store/$d" ] || return 1; echo "$store/$d/$m" ;;
*) [ -f "$store/$n" ] || return 1; echo "$store/$n" ;; esac ;;
*) echo "$1" ;;
esac
}
src=$(map "$1") || { echo "cp: no such data set" >&2; exit 1; }
dst=$(map "$2") || { echo "cp: data set not allocated" >&2; exit 1; }
[ -e "$src" ] || [ "$src" = /dev/fd/0 ] || { echo "cp: $1: not found" >&2; exit 1; }
case $2 in
"//'"*\(*) cat "$src" | awk '{ printf "%-80s\n", $0 }' >"$dst" ;;
*) cat "$src" >"$dst" ;;
esac
|