#!/bin/bash # ref_resolvers/lua.sh # Resolves a Lua manual section reference to its full URL. # The reference name is read from stdin. # Outputs the URL to stdout. reference="$(cat)" webroot="https://www.lua.org/manual/5.2/manual.html" case $(echo $reference | tr '[:upper:]' '[:lower:]') in "introduction") printf "%s#%s" "$webroot" "1" exit 0 ;; "basic concepts") printf "%s#%s" "$webroot" "2" exit 0 ;; "values and types") printf "%s#%s" "$webroot" "2.1" exit 0 ;; "environments and the global environment") printf "%s#%s" "$webroot" "2.2" exit 0 ;; "error handling") printf "%s#%s" "$webroot" "2.3" exit 0 ;; "metatables and metamethods") printf "%s#%s" "$webroot" "2.4" exit 0 ;; "garbage collection") printf "%s#%s" "$webroot" "2.5" exit 0 ;; "garbage-collection metamethods") printf "%s#%s" "$webroot" "2.5.1" exit 0 ;; "weak tables") printf "%s#%s" "$webroot" "2.5.2" exit 0 ;; "coroutines") printf "%s#%s" "$webroot" "2.6" exit 0 ;; "the language") printf "%s#%s" "$webroot" "3" exit 0 ;; "lexical conventions") printf "%s#%s" "$webroot" "3.1" exit 0 ;; "variables") printf "%s#%s" "$webroot" "3.2" exit 0 ;; "statements") printf "%s#%s" "$webroot" "3.3" exit 0 ;; "blocks") printf "%s#%s" "$webroot" "3.3.1" exit 0 ;; "chunks") printf "%s#%s" "$webroot" "3.3.2" exit 0 ;; "assignment") printf "%s#%s" "$webroot" "3.3.3" exit 0 ;; "control structures") printf "%s#%s" "$webroot" "3.3.4" exit 0 ;; "for statement") printf "%s#%s" "$webroot" "3.3.5" exit 0 ;; "function calls as statements") printf "%s#%s" "$webroot" "3.3.6" exit 0 ;; "local declarations") printf "%s#%s" "$webroot" "3.3.7" exit 0 ;; "expressions") printf "%s#%s" "$webroot" "3.4" exit 0 ;; "arithmetic operators") printf "%s#%s" "$webroot" "3.4.1" exit 0 ;; "coercion") printf "%s#%s" "$webroot" "3.4.2" exit 0 ;; "relational operators") printf "%s#%s" "$webroot" "3.4.3" exit 0 ;; "logical operators") printf "%s#%s" "$webroot" "3.4.4" exit 0 ;; "concatenation") printf "%s#%s" "$webroot" "3.4.5" exit 0 ;; "the length operator") printf "%s#%s" "$webroot" "3.4.6" exit 0 ;; "precedence") printf "%s#%s" "$webroot" "3.4.7" exit 0 ;; "table constructors") printf "%s#%s" "$webroot" "3.4.8" exit 0 ;; "function calls") printf "%s#%s" "$webroot" "3.4.9" exit 0 ;; "function definitions") printf "%s#%s" "$webroot" "3.4.10" exit 0 ;; "visibility rules") printf "%s#%s" "$webroot" "3.5" exit 0 ;; "the application program interface") printf "%s#%s" "$webroot" "4" exit 0 ;; "the stack") printf "%s#%s" "$webroot" "4.1" exit 0 ;; "stack size") printf "%s#%s" "$webroot" "4.2" exit 0 ;; "valid and acceptable indices") printf "%s#%s" "$webroot" "4.3" exit 0 ;; "c closures") printf "%s#%s" "$webroot" "4.4" exit 0 ;; "registry") printf "%s#%s" "$webroot" "4.5" exit 0 ;; "error handling in c") printf "%s#%s" "$webroot" "4.6" exit 0 ;; "handling yields in c") printf "%s#%s" "$webroot" "4.7" exit 0 ;; "functions and types") # Matches section 4.8 (C API). Section 5.1 (Auxiliary Library) has the # same title; this entry resolves to the first occurrence. printf "%s#%s" "$webroot" "4.8" exit 0 ;; "the debug interface") printf "%s#%s" "$webroot" "4.9" exit 0 ;; "the auxiliary library") printf "%s#%s" "$webroot" "5" exit 0 ;; "standard libraries") printf "%s#%s" "$webroot" "6" exit 0 ;; "basic functions") printf "%s#%s" "$webroot" "6.1" exit 0 ;; "coroutine manipulation") printf "%s#%s" "$webroot" "6.2" exit 0 ;; "modules") printf "%s#%s" "$webroot" "6.3" exit 0 ;; "string manipulation") printf "%s#%s" "$webroot" "6.4" exit 0 ;; "patterns") printf "%s#%s" "$webroot" "6.4.1" exit 0 ;; "table manipulation") printf "%s#%s" "$webroot" "6.5" exit 0 ;; "mathematical functions") printf "%s#%s" "$webroot" "6.6" exit 0 ;; "bitwise operations") printf "%s#%s" "$webroot" "6.7" exit 0 ;; "input and output facilities") printf "%s#%s" "$webroot" "6.8" exit 0 ;; "operating system facilities") printf "%s#%s" "$webroot" "6.9" exit 0 ;; "the debug library") printf "%s#%s" "$webroot" "6.10" exit 0 ;; "lua standalone") printf "%s#%s" "$webroot" "7" exit 0 ;; "incompatibilities with the previous version") printf "%s#%s" "$webroot" "8" exit 0 ;; "changes in the language") printf "%s#%s" "$webroot" "8.1" exit 0 ;; "changes in the libraries") printf "%s#%s" "$webroot" "8.2" exit 0 ;; "changes in the api") printf "%s#%s" "$webroot" "8.3" exit 0 ;; "the complete syntax of lua") printf "%s#%s" "$webroot" "9" exit 0 ;; # Lua type names — resolve to the Values and Types section (2.1) "nil" \ | "boolean" \ | "number" \ | "string" \ | "function" \ | "userdata" \ | "thread" \ | "table") printf "%s#%s" "$webroot" "2.1" exit 0 ;; # Alternative lowercase spelling for coroutines "coroutines") printf "%s#%s" "$webroot" "2.6" exit 0 ;; esac