10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-19 04:22:32 +01:00
QuantumPackage/bin/zcat
2023-04-18 15:55:43 +02:00

23 lines
395 B
Bash
Executable File

#!/bin/bash
# On Darwin: try gzcat if available, otherwise use Python
if [[ $(uname -s) = Darwin ]] ; then
which gzcat &> /dev/null
if [[ $? -eq 0 ]] ; then
exec gzcat $@
else
exec python3 << EOF
import sys
import gzip
with gzip.open("$1", "rt") as f:
print(f.read())
EOF
fi
else
command=$(which -a zcat | grep -v 'qp2/bin/' | head -1)
exec $command $@
fi