Bash Windows Hyphen Check
So, a typical thing I see is that people got a documentation in front of them - great!
Even better if this doc is even up-to-date. Most of the time it’s a Word document with default settings.
That means: whenever you type --
it will be auto-formatted to a “longer” hyphen. Now this is a real cause of issues. Cause on the console there is no error message which says: “hey, looks like your hyphen is wrong!”
This small function which I used in a bunch of bash scripts:
check_windows_hyphen(){
echo $1 | od -cb | grep "342 200 223" > /dev/null
RETURNCODE=$?
if [ $RETURNCODE -eq 0 ]; then
echo "copy & paste from documentation? check the hyphen."
exit 1
fi
}
Read other posts