10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-07-05 19:06:05 +02:00
QuantumPackage/bin/zcat

23 lines
395 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)
2023-04-18 15:55:43 +02:00
exec $command $@
2023-04-18 11:27:51 +02:00
fi
2023-04-18 11:20:51 +02:00