Last active
November 14, 2017 20:07
-
-
Save stephenreay/339d01d6fc6239c3089810cbdca2f4cf to your computer and use it in GitHub Desktop.
sh vs osh errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Should work, but doesnt" | |
printf "%s\n" "Hello World" | |
/usr/bin/printf "%s\n" "Goodbye Universe" | |
echo "" | |
echo "Works" | |
printf "%s\\n" "Hello World" | |
/usr/bin/printf "%s\\n" "Goodbye Universe" | |
echo "" | |
echo "Also works" | |
printf '%s\n' "Hello World" | |
/usr/bin/printf '%s\n' "Goodbye Universe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
k_gpg_keyid_valid_old() { | |
local keyId="$1" | |
if [ "${keyId%%0x*}" = "" ] && [ ${#keyId} -eq 10 -o ${#keyId} -eq 18 ]; then | |
keyId="${keyId#0x}" | |
fi | |
[ ${#keyId} -eq 8 -o ${#keyId} -eq 16 ] && [ "${keyId}" = "$(printf "%s" "${keyId}" | tr -c -d 'ABCDEFabcdef0123456789')" ] | |
} | |
k_gpg_keyid_valid() { | |
local keyId="$1" | |
if [ "${keyId%%0x*}" = "" ] && ([ ${#keyId} -eq 10 ] || [ ${#keyId} -eq 18 ]); then | |
keyId="${keyId#0x}" | |
fi | |
([ ${#keyId} -eq 8 ] || [ ${#keyId} -eq 16 ]) && [ "${keyId}" = "$(printf "%s" "${keyId}" | tr -c -d 'ABCDEFabcdef0123456789')" ] | |
} | |
echo "Works" | |
if k_gpg_keyid_valid abc; then | |
echo "valid key" | |
else | |
echo "invalid key" | |
fi | |
if k_gpg_keyid_valid AD11C35B; then | |
echo "valid key" | |
else | |
echo "invalid key" | |
fi | |
echo "" | |
echo "Should work, but doesn't" | |
if k_gpg_keyid_valid_old abc; then | |
echo "valid key" | |
else | |
echo "invalid key" | |
fi | |
if k_gpg_keyid_valid_old AD11C35B; then | |
echo "valid key" | |
else | |
echo "invalid key" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment