2019-05-18 18:49:47 +00:00
|
|
|
#!/bin/sh -
|
|
|
|
|
|
|
|
PATH=/usr/bin
|
|
|
|
|
|
|
|
off=0
|
|
|
|
strlen=0
|
|
|
|
|
|
|
|
if [ $# -eq 0 -a ! -t 0 ]; then
|
|
|
|
file=/dev/stdin
|
|
|
|
elif [ $# -eq 1 ]; then
|
|
|
|
file=$1
|
|
|
|
else
|
|
|
|
echo Usage: ${0##*/} [file]
|
|
|
|
echo converts OpenVMS variable-length record format to unix text format
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
off=$((${off} + ${strlen}))
|
2020-05-21 04:22:51 +00:00
|
|
|
# read in 1-byte units
|
|
|
|
set -- $(od -An -tu1 -j${off} -N2 ${file})
|
2019-05-18 18:49:47 +00:00
|
|
|
# EoF
|
2020-05-21 04:22:51 +00:00
|
|
|
[ -z "${1}" -o -z "${2}" ] && break
|
|
|
|
# assume little-endian, it's OpenVMS format
|
|
|
|
strlen=$(($2 * 256 + $1))
|
2019-05-18 18:49:47 +00:00
|
|
|
# print newline for zero-size records, as info-zip does
|
|
|
|
[ ${strlen} -eq 0 ] && echo
|
|
|
|
off=$((${off} + 2))
|
2020-05-21 04:22:51 +00:00
|
|
|
hexdump -s ${off} -n ${strlen} -e '"'%.${strlen}s'"''"\n"' ${file}
|
2019-05-18 18:49:47 +00:00
|
|
|
# align 2
|
|
|
|
[ $((${strlen} % 2)) -ne 0 ] && off=$((${off} + 1))
|
|
|
|
done
|