Rewrite aa-decode to use inline Python instead of to-be-deprecated Perl

This commit is contained in:
Otto Kekäläinen 2019-02-03 21:41:03 +01:00
parent a3ae271d1e
commit 707ef17923

View file

@ -37,8 +37,12 @@ EOM
}
decode() {
decoded=`perl -le "\\$s = uc('$1') ; if (\\$s =~ /^[0-9A-F]*$/) { print pack 'H*', \\$s; }"`
echo "$decoded"
if echo "$1" | egrep -q "^[0-9A-Fa-f]+$" ; then
python3 -c "import binascii; print(bytes.decode(binascii.unhexlify('$1'), errors='strict'));"
else
echo ""
fi
}
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
@ -92,4 +96,3 @@ while read line ; do
echo "$line"
done