#!/bin/sh # The MIT License (MIT) # # Copyright © 2024 pacman64 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the “Software”), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # sym [names...] # # Lookup various hard-to-type symbols by their common names/aliases. All/any # dashes in the names given are ignored, and are thus supported, so to speak. # handle help options case "$1" in -h|--h|-help|--help) awk '/^# +sym/, /^$/ { gsub(/^# ?/, ""); print }' "$0" exit 0 ;; esac # when given no names, show (almost) all name-symbol pairs supported if [ $# -eq 0 ]; then # show all built-in `here-doc` entries from this very script/file awk '/^[a-z]/ && NF == 2' "${0}" exit 0 fi # lookup built-in dataset awk -v allnames="${*}" ' # figure out which names to lookup, and handle special names upfront BEGIN { # lowercase symbol names, also ignoring any dashes in them allnames = tolower(allnames) gsub(/[_-]/, "", allnames) gsub(/^ +| +$/, "", allnames) # split space-separated items into an array named `symbols` split(allnames, symbols, / +/) # special-handle a few entries which either span multiple lines, # have whitespace-like symbols in them, or both special["cr"] = "\r" # no trailing LF special["crlf"] = "\r\n" special["formfeed"] = "\f\n" special["lf"] = "\n" special["linefeed"] = "\n" special["nil"] = "\0\n" special["nul"] = "\0\n" special["null"] = "\0\n" special["space"] = " \n" special["tab"] = "\t\n" special["vtab"] = "\v\n" special["whitespace"] = " \t\n\r\f\v" # no trailing LF for (i in symbols) { if (symbols[i] == "ascii") { # the full ASCII set, with no extra LF after it matches[i]++ for (n = 0; n < 128; n++) { printf "%c", n } continue } if (special[symbols[i]] == "") { continue } # a special name matched matches[i]++ printf special[symbols[i]] } } # try to match each symbol to each built-in data line { for (i in symbols) { if ($1 == symbols[i]) { matches[i]++ print $2 next } } } # report any not-found-type errors END { fs = "\x1b[31mno matching symbols found for `%s`\x1b[0m\n" for (i in symbols) { if (matches[i] == 0) { printf fs, symbols[i] failures++ } } if (failures > 0) { exit 1 } }' << 'ENDOFDATA' adash - aeq ≈ almost ≈ amp & ampersand & apos ’ apostrophe ’ approx ≅ asterisk * atleast ≥ atmost ≤ backquote ` backslash \ backtick ` ball ● bang ! base64 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= block █ bquo ` bquote ` bslash \ bullet • caret ^ cdot · circle ● cloud ☁️ colon : comma , copyright © cquote ” crap 💩 crapface 💩 cross × dash — deg ° degree ° doc 📄 document 📄 dollar $ dot . dquo " dquote " doublequote " ellip … ellipsis … email @ emdash — endash – eq = equal = equals = excl ! exclam ! exclamation ! faces 😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟😠😡😢😣😤😥😦😧😨😩😪😫😬😭😮😯😰😱😲😳😴😵😶😷🙁🙂🙃🙄🧐👶🤓🤐🤑🤒🤔🤕🤗🤠🤡🤢🤣🤤🤥🤧🤨🤩🤪🤫🤬🤭🤮🤯 file 📄 fullmoon 🌕 fullstop . geq ≥ greatereq ≥ happy 😀 happyface 😀 heart ❤️ hellip … hole ○ hyphen - leq ≤ less < lesseq ≤ lightning 🌩️ ldquo “ ldquote “ lsquo ‘ lsquote ‘ mdash — mdot · more > music 🎵 musicalnote 🎵 ndash – neq ≠ not ¬ notequal ≠ notequals ≠ oquote “ period . pipe | question ? rain 🌧️ rdquo ” rdquote ” rsquo ’ rsquote ’ semicolon ; sharp # shit 💩 shitface 💩 slash / slasher ⧸ slashier ⧸ smile 🙂 smileface 🙂 smilingface 🙂 snow ❄️ square ■ squo ' squote ' singlequote ' star ⭐ sun ☀️ tilde ~ vbar | vellip ⋮ alpha α beta β delta δ eps ε epsilon ε gamma γ lambda λ omega ω pi π sigma σ tau τ theta θ alphabet abcdefghijklmnopqrstuvwxyz asciiletters abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ digits 0123456789 greek αβγδεζηθικλμνξοπρστυφχψω hex 0123456789abcdef hexa 0123456789abcdef hexadec 0123456789abcdef hexadecimal 0123456789abcdef hexdigits 0123456789abcdefABCDEF inf ∞ infinity ∞ latin abcdefghijklmnopqrstuvwxyz letters abcdefghijklmnopqrstuvwxyz lower abcdefghijklmnopqrstuvwxyz lowercase abcdefghijklmnopqrstuvwxyz lowercasegreek αβγδεζηθικλμνξοπρστυφχψω lowergreek αβγδεζηθικλμνξοπρστυφχψω lowercasehex 0123456789abcdef lowerhex 0123456789abcdef math +-×÷²³± midascii !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ octal 01234567 octaldigits 01234567 octdigits 01234567 other ✓✗✔❌ plusminus ± prod Π product Π punct !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ punctuation !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ sum Σ summation Σ upper ABCDEFGHIJKLMNOPQRSTUVWXYZ uppercase ABCDEFGHIJKLMNOPQRSTUVWXYZ uppercasegreek ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ uppergreek ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ uppercasehex 0123456789ABCDEF upperhex 0123456789ABCDEF aud A$ brl R$ cad C$ chf CHF clp CLP cny 元 czk Kč dkk DKK eur € gbp £ hkd HK$ huf Ft idr Rp ils ₪ inr ₹ jpy ¥ krw ₩ mxn MXN nok NOK nzd NZ$ php ₱ pln zł rub ₽ sar ﷼ sek SEK sgd S$ thb ฿ try ₺ twd NT$ usd $ zar R baht ฿ britishpound £ cent ¢ cents ¢ euro € indianrupee ₹ koruna Kč naira ₦ newshekel ₪ philippinepeso ₱ pound £ poundsterling £ renminbi 元 riyal ﷼ ruble ₽ rupee ₹ saudiriyal ﷼ shekel ₪ sterling £ turkishlira ₺ won ₩ yen ¥ zloty zł afghanistan 🇦🇫 america 🇺🇸 algeria 🇩🇿 angola 🇦🇴 arabia 🇸🇦 arabemirates 🇦🇪 argentina 🇦🇷 australia 🇦🇺 austria 🇦🇹 bangladesh 🇧🇩 belgium 🇧🇪 brazil 🇧🇷 britain 🇬🇧 canada 🇨🇦 chile 🇨🇱 china 🇨🇳 colombia 🇨🇴 czechia 🇨🇿 czechrepublic 🇨🇿 denmark 🇩🇰 dominicanrepublic 🇩🇴 drc 🇨🇩 drcongo 🇨🇩 ecuador 🇪🇨 egypt 🇪🇬 emirates 🇦🇪 england 🇬🇧 ethiopia 🇪🇹 europe 🇪🇺 europeanunion 🇪🇺 finland 🇫🇮 france 🇫🇷 germany 🇩🇪 ghana 🇬🇭 greatbritain 🇬🇧 greece 🇬🇷 holland 🇳🇱 hungary 🇭🇺 india 🇮🇳 indonesia 🇮🇩 iran 🇮🇷 iraq 🇮🇶 ireland 🇮🇪 israel 🇮🇱 italy 🇮🇹 japan 🇯🇵 kazakhstan 🇰🇿 kenya 🇰🇪 korea 🇰🇷 kuwait 🇰🇼 madagascar 🇲🇬 malaysia 🇲🇾 mexico 🇲🇽 morocco 🇲🇦 mozambique 🇲🇿 myanmar 🇲🇲 nepal 🇳🇵 netherlands 🇳🇱 newzealand 🇳🇿 nigeria 🇳🇬 northkorea 🇰🇵 norway 🇳🇴 pakistan 🇵🇰 peru 🇵🇪 philippines 🇵🇭 poland 🇵🇱 portugal 🇵🇹 qatar 🇶🇦 rok 🇰🇷 romania 🇷🇴 russia 🇷🇺 saudiarabia 🇸🇦 singapore 🇸🇬 somalia 🇸🇴 southafrica 🇿🇦 southkorea 🇰🇷 spain 🇪🇸 srilanka 🇱🇰 sudan 🇸🇩 sweden 🇸🇪 switzerland 🇨🇭 taiwan 🇹🇼 tanzania 🇹🇿 thailand 🇹🇭 turkey 🇹🇷 uganda 🇺🇬 ukraine 🇺🇦 unitedarab 🇦🇪 unitedarabemirates 🇦🇪 unitedemirates 🇦🇪 unitedkingdom 🇬🇧 unitedstates 🇺🇸 uzbekistan 🇺🇿 yemen 🇾🇪 venezuela 🇻🇪 vietnam 🇻🇳 af 🇦🇫 ax 🇦🇽 al 🇦🇱 dz 🇩🇿 as 🇦🇸 ad 🇦🇩 ao 🇦🇴 ai 🇦🇮 aq 🇦🇶 ag 🇦🇬 ar 🇦🇷 am 🇦🇲 aw 🇦🇼 au 🇦🇺 at 🇦🇹 az 🇦🇿 bs 🇧🇸 bh 🇧🇭 bd 🇧🇩 bb 🇧🇧 by 🇧🇾 be 🇧🇪 bz 🇧🇿 bj 🇧🇯 bm 🇧🇲 bt 🇧🇹 bo 🇧🇴 bq 🇧🇶 ba 🇧🇦 bw 🇧🇼 bv 🇧🇻 br 🇧🇷 io 🇮🇴 bn 🇧🇳 bg 🇧🇬 bf 🇧🇫 bi 🇧🇮 cv 🇨🇻 kh 🇰🇭 cm 🇨🇲 ca 🇨🇦 ky 🇰🇾 cf 🇨🇫 td 🇹🇩 cl 🇨🇱 cn 🇨🇳 cx 🇨🇽 cc 🇨🇨 co 🇨🇴 km 🇰🇲 cd 🇨🇩 cg 🇨🇬 ck 🇨🇰 cr 🇨🇷 ci 🇨🇮 hr 🇭🇷 cu 🇨🇺 cw 🇨🇼 cy 🇨🇾 cz 🇨🇿 dk 🇩🇰 dj 🇩🇯 dm 🇩🇲 do 🇩🇴 ec 🇪🇨 eg 🇪🇬 sv 🇸🇻 gq 🇬🇶 er 🇪🇷 ee 🇪🇪 sz 🇸🇿 et 🇪🇹 eu 🇪🇺 fk 🇫🇰 fo 🇫🇴 fj 🇫🇯 fi 🇫🇮 fr 🇫🇷 gf 🇬🇫 pf 🇵🇫 tf 🇹🇫 ga 🇬🇦 gm 🇬🇲 ge 🇬🇪 de 🇩🇪 gh 🇬🇭 gi 🇬🇮 gr 🇬🇷 gl 🇬🇱 gd 🇬🇩 gp 🇬🇵 gu 🇬🇺 gt 🇬🇹 gg 🇬🇬 gn 🇬🇳 gw 🇬🇼 gy 🇬🇾 ht 🇭🇹 hm 🇭🇲 va 🇻🇦 hn 🇭🇳 hk 🇭🇰 hu 🇭🇺 is 🇮🇸 in 🇮🇳 id 🇮🇩 ir 🇮🇷 iq 🇮🇶 ie 🇮🇪 im 🇮🇲 il 🇮🇱 it 🇮🇹 jm 🇯🇲 jp 🇯🇵 je 🇯🇪 jo 🇯🇴 kz 🇰🇿 ke 🇰🇪 ki 🇰🇮 kp 🇰🇵 kr 🇰🇷 kw 🇰🇼 kg 🇰🇬 la 🇱🇦 lv 🇱🇻 lb 🇱🇧 ls 🇱🇸 lr 🇱🇷 ly 🇱🇾 li 🇱🇮 lt 🇱🇹 lu 🇱🇺 mo 🇲🇴 mk 🇲🇰 mg 🇲🇬 mw 🇲🇼 my 🇲🇾 mv 🇲🇻 ml 🇲🇱 mt 🇲🇹 mh 🇲🇭 mq 🇲🇶 mr 🇲🇷 mu 🇲🇺 yt 🇾🇹 mx 🇲🇽 fm 🇫🇲 md 🇲🇩 mc 🇲🇨 mn 🇲🇳 me 🇲🇪 ms 🇲🇸 ma 🇲🇦 mz 🇲🇿 mm 🇲🇲 na 🇳🇦 nr 🇳🇷 np 🇳🇵 nl 🇳🇱 nc 🇳🇨 nz 🇳🇿 ni 🇳🇮 ne 🇳🇪 ng 🇳🇬 nu 🇳🇺 nf 🇳🇫 mp 🇲🇵 no 🇳🇴 om 🇴🇲 pk 🇵🇰 pw 🇵🇼 ps 🇵🇸 pa 🇵🇦 pg 🇵🇬 py 🇵🇾 pe 🇵🇪 ph 🇵🇭 pn 🇵🇳 pl 🇵🇱 pt 🇵🇹 pr 🇵🇷 qa 🇶🇦 re 🇷🇪 ro 🇷🇴 ru 🇷🇺 rw 🇷🇼 bl 🇧🇱 sh 🇸🇭 kn 🇰🇳 lc 🇱🇨 mf 🇲🇫 pm 🇵🇲 vc 🇻🇨 ws 🇼🇸 sm 🇸🇲 st 🇸🇹 sa 🇸🇦 sn 🇸🇳 rs 🇷🇸 sc 🇸🇨 sl 🇸🇱 sg 🇸🇬 sx 🇸🇽 sk 🇸🇰 si 🇸🇮 sb 🇸🇧 so 🇸🇴 za 🇿🇦 gs 🇬🇸 ss 🇸🇸 es 🇪🇸 lk 🇱🇰 sd 🇸🇩 sr 🇸🇷 sj 🇸🇯 se 🇸🇪 ch 🇨🇭 sy 🇸🇾 tw 🇹🇼 tj 🇹🇯 tz 🇹🇿 th 🇹🇭 tl 🇹🇱 tg 🇹🇬 tk 🇹🇰 to 🇹🇴 tt 🇹🇹 tn 🇹🇳 tr 🇹🇷 tm 🇹🇲 tc 🇹🇨 tv 🇹🇻 ug 🇺🇬 ua 🇺🇦 ae 🇦🇪 gb 🇬🇧 um 🇺🇲 us 🇺🇸 uy 🇺🇾 uz 🇺🇿 vu 🇻🇺 ve 🇻🇪 vn 🇻🇳 vg 🇻🇬 vi 🇻🇮 wf 🇼🇫 eh 🇪🇭 ye 🇾🇪 zm 🇿🇲 zw 🇿🇼 afg 🇦🇫 ala 🇦🇽 alb 🇦🇱 dza 🇩🇿 asm 🇦🇸 and 🇦🇩 ago 🇦🇴 aia 🇦🇮 ata 🇦🇶 atg 🇦🇬 arg 🇦🇷 arm 🇦🇲 abw 🇦🇼 aus 🇦🇺 aut 🇦🇹 aze 🇦🇿 bhs 🇧🇸 bhr 🇧🇭 bgd 🇧🇩 brb 🇧🇧 blr 🇧🇾 bel 🇧🇪 blz 🇧🇿 ben 🇧🇯 bmu 🇧🇲 btn 🇧🇹 bol 🇧🇴 bes 🇧🇶 bih 🇧🇦 bwa 🇧🇼 bvt 🇧🇻 bra 🇧🇷 iot 🇮🇴 brn 🇧🇳 bgr 🇧🇬 bfa 🇧🇫 bdi 🇧🇮 cpv 🇨🇻 khm 🇰🇭 cmr 🇨🇲 can 🇨🇦 cym 🇰🇾 caf 🇨🇫 tcd 🇹🇩 chl 🇨🇱 chn 🇨🇳 cxr 🇨🇽 cck 🇨🇨 col 🇨🇴 com 🇰🇲 cod 🇨🇩 cog 🇨🇬 cok 🇨🇰 cri 🇨🇷 civ 🇨🇮 hrv 🇭🇷 cub 🇨🇺 cuw 🇨🇼 cyp 🇨🇾 cze 🇨🇿 dnk 🇩🇰 dji 🇩🇯 dma 🇩🇲 dom 🇩🇴 ecu 🇪🇨 egy 🇪🇬 slv 🇸🇻 gnq 🇬🇶 eri 🇪🇷 est 🇪🇪 swz 🇸🇿 eth 🇪🇹 flk 🇫🇰 fro 🇫🇴 fji 🇫🇯 fin 🇫🇮 fra 🇫🇷 guf 🇬🇫 pyf 🇵🇫 atf 🇹🇫 gab 🇬🇦 gmb 🇬🇲 geo 🇬🇪 deu 🇩🇪 gha 🇬🇭 gib 🇬🇮 grc 🇬🇷 grl 🇬🇱 grd 🇬🇩 glp 🇬🇵 gum 🇬🇺 gtm 🇬🇹 ggy 🇬🇬 gin 🇬🇳 gnb 🇬🇼 guy 🇬🇾 hti 🇭🇹 hmd 🇭🇲 vat 🇻🇦 hnd 🇭🇳 hkg 🇭🇰 hun 🇭🇺 isl 🇮🇸 ind 🇮🇳 idn 🇮🇩 irn 🇮🇷 irq 🇮🇶 irl 🇮🇪 imn 🇮🇲 isr 🇮🇱 ita 🇮🇹 jam 🇯🇲 jpn 🇯🇵 jey 🇯🇪 jor 🇯🇴 kaz 🇰🇿 ken 🇰🇪 kir 🇰🇮 prk 🇰🇵 kor 🇰🇷 kwt 🇰🇼 kgz 🇰🇬 lao 🇱🇦 lva 🇱🇻 lbn 🇱🇧 lso 🇱🇸 lbr 🇱🇷 lby 🇱🇾 lie 🇱🇮 ltu 🇱🇹 lux 🇱🇺 mac 🇲🇴 mkd 🇲🇰 mdg 🇲🇬 mwi 🇲🇼 mys 🇲🇾 mdv 🇲🇻 mli 🇲🇱 mlt 🇲🇹 mhl 🇲🇭 mtq 🇲🇶 mrt 🇲🇷 mus 🇲🇺 myt 🇾🇹 mex 🇲🇽 fsm 🇫🇲 mda 🇲🇩 mco 🇲🇨 mng 🇲🇳 mne 🇲🇪 msr 🇲🇸 mar 🇲🇦 moz 🇲🇿 mmr 🇲🇲 nam 🇳🇦 nru 🇳🇷 npl 🇳🇵 nld 🇳🇱 ncl 🇳🇨 nzl 🇳🇿 nic 🇳🇮 ner 🇳🇪 nga 🇳🇬 niu 🇳🇺 nfk 🇳🇫 mnp 🇲🇵 nor 🇳🇴 omn 🇴🇲 pak 🇵🇰 plw 🇵🇼 pse 🇵🇸 pan 🇵🇦 png 🇵🇬 pry 🇵🇾 per 🇵🇪 phl 🇵🇭 pcn 🇵🇳 pol 🇵🇱 prt 🇵🇹 pri 🇵🇷 qat 🇶🇦 reu 🇷🇪 rou 🇷🇴 rus 🇷🇺 rwa 🇷🇼 blm 🇧🇱 shn 🇸🇭 kna 🇰🇳 lca 🇱🇨 maf 🇲🇫 spm 🇵🇲 vct 🇻🇨 wsm 🇼🇸 smr 🇸🇲 stp 🇸🇹 sau 🇸🇦 sen 🇸🇳 srb 🇷🇸 syc 🇸🇨 sle 🇸🇱 sgp 🇸🇬 sxm 🇸🇽 svk 🇸🇰 svn 🇸🇮 slb 🇸🇧 som 🇸🇴 zaf 🇿🇦 sgs 🇬🇸 ssd 🇸🇸 esp 🇪🇸 lka 🇱🇰 sdn 🇸🇩 sur 🇸🇷 sjm 🇸🇯 swe 🇸🇪 che 🇨🇭 syr 🇸🇾 twn 🇹🇼 tjk 🇹🇯 tza 🇹🇿 tha 🇹🇭 tls 🇹🇱 tgo 🇹🇬 tkl 🇹🇰 ton 🇹🇴 tto 🇹🇹 tun 🇹🇳 tur 🇹🇷 tkm 🇹🇲 tca 🇹🇨 tuv 🇹🇻 uga 🇺🇬 ukr 🇺🇦 are 🇦🇪 gbr 🇬🇧 uae 🇦🇪 umi 🇺🇲 usa 🇺🇸 ury 🇺🇾 uzb 🇺🇿 vut 🇻🇺 ven 🇻🇪 vnm 🇻🇳 vgb 🇻🇬 vir 🇻🇮 wlf 🇼🇫 esh 🇪🇭 yem 🇾🇪 zmb 🇿🇲 zwe 🇿🇼 ENDOFDATA