10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-22 20:34:58 +01:00
QuantumPackage/bin/zcat

23 lines
391 B
Plaintext
Raw Normal View History

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