1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 13:16:44 +02:00

oeis: awk toupper(), case insensitive language search

This commit is contained in:
Your Name
2020-06-19 08:00:20 -04:00
parent 73a9a53456
commit 89f69bbd40
+1 -5
View File
@@ -112,11 +112,7 @@ oeis() (
> ${TMP}/prog
# Print out code sample for specified language
rm -f ${TMP}/code_snippet
awk -v tgt="${LANGUAGE^^}" -F'[()]' '/^\(/{f=(tgt==$2)} f' ${TMP}/prog > ${TMP}/code_snippet
L="${LANGUAGE:0:1}"
LANGUAGE="${LANGUAGE:1}"
LANGUAGE="${L^^}${LANGUAGE,,}"
[ $(wc -c < $TMP/code_snippet) -eq 0 ] && awk -v tgt="${LANGUAGE}" -F'[()]' '/^\(/{f=(tgt==$2)} f' ${TMP}/prog > ${TMP}/code_snippet
awk -v tgt="${LANGUAGE^^}" -F'[()]' '/^\(/{f=(tgt==toupper($2))} f' ${TMP}/prog > ${TMP}/code_snippet
fi
# Print code snippet with 4-space indent to enable colorization
if [ $(wc -c < $TMP/code_snippet) -ne 0 ]