10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-03 20:53:54 +01:00
QuantumPackage/bin/zcat

24 lines
469 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
2023-11-07 11:28:18 +01:00
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
command=$(which -a zcat | grep -v "$SCRIPTPATH/" | 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