9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-23 12:03:30 +01:00
qp2/scripts/utility/qp_clean_source_files.sh
2020-03-31 19:02:03 +02:00

41 lines
701 B
Bash
Executable File

#!/bin/bash
#
# Cleans the source files from non-ascii characters
#
# Tue Mar 31 18:28:42 CEST 2020
#
function help() {
cat << EOF
Cleans the source files of QP from non-ascii characters.
Usage:
$(basename $0) [-h|--help]
Options:
-h --help Prints the help message
EOF
exit 0
}
# Check the QP_ROOT directory
if [[ -z ${QP_ROOT} ]] ; then
echo "The QP_ROOT environment variable is not set."
echo "Please reload the quantum_package.rc file."
exit 1
fi
FILES=$(grep -e "[\x{00FF}-\x{FFFF}]" ${QP_ROOT}/src/*/*.f | cut -d ':' -f 1 | sort | uniq)
for F in $FILES ; do
echo "Cleaning $F"
# vim -c "% s/\%xA0/ /g" -c ":wq" $F
perl -pi -e 's/[^[:ascii:]]/ /g' $F
done