Make quoting consistent

This commit is contained in:
The Magician 2023-11-05 19:09:42 +00:00
parent 6558464cb0
commit b0f6e4f4c8
1 changed files with 35 additions and 35 deletions

View File

@ -3,23 +3,23 @@
set -e set -e
thebookofcolors() { thebookofcolors() {
printf '\e[4;7;36m' printf "\e[4;7;36m"
if test -z "$1"; then if test -z "$1"; then
printf 'The Book of Colors' printf "The Book of Colors"
else else
printf "$1" printf "$1"
fi fi
printf '\e[0m' printf "\e[0m"
} }
newline() { newline() {
if test -z "$1"; then if test -z "$1"; then
printf '\n' printf "\n"
return return
fi fi
for i in $(seq 1 $1); do for i in $(seq 1 $1); do
printf '\n' printf "\n"
done done
} }
@ -29,71 +29,71 @@ title() {
exit 1 exit 1
fi fi
printf '\e[1;4;37m' printf "\e[1;4;37m"
printf "$1" printf "$1"
printf '\e[0m\n' printf "\e[0m\n"
} }
section_introduction() { section_introduction() {
title "Introduction" title "Introduction"
thebookofcolors thebookofcolors
printf ' is an in-terminal manual on ANSI escape codes, or "color codes", for use in terminal emulators.\n' printf " is an in-terminal manual on ANSI escape codes, or \"color codes\", for use in terminal emulators.\n"
printf 'Examples are given not only in written form, but "practical" form -- every escape code and option described in ' printf "Examples are given not only in written form, but \"practical\" form -- every escape code and option described in "
thebookofcolors thebookofcolors
printf ' is used in ' printf " is used in "
thebookofcolors "The Book" thebookofcolors "The Book"
printf ' itself.\n' printf " itself.\n"
} }
section_disclaimers() { section_disclaimers() {
title "Disclaimers" title "Disclaimers"
thebookofcolors thebookofcolors
printf ' is open-source software and is provided as-is with NO WARRANTY under applicable law.\n' printf " is open-source software and is provided as-is with NO WARRANTY under applicable law.\n"
printf 'If any escape codes persist to your terminal session after viewing ' printf "If any escape codes persist to your terminal session after viewing "
thebookofcolors "The Book" thebookofcolors "The Book"
printf ', use the `reset` command to restore your terminal.\n' printf ", use the \`reset\` command to restore your terminal.\n"
printf 'If you believe you have found a bug, please open an issue on the repository, which can be found at <REPOSITORY_URL_GOES_HERE>.\n' printf "If you believe you have found a bug, please open an issue on the repository, which can be found at <REPOSITORY_URL_GOES_HERE>.\n"
printf 'If you have a fix for said bug, please submit a pull request instead.\n' printf "If you have a fix for said bug, please submit a pull request instead.\n"
} }
section_anatomy() { section_anatomy() {
title "Anatomy of an ANSI Escape Code" title "Anatomy of an ANSI Escape Code"
printf 'Escape codes begin with `\\e`, `\\033`, or `\\x1b`. These are all three different escape sequences which insert the ASCII character 27, or ESC. (This is why they''re called ANSI "escape" codes, because they begin with a literal escape character). The syntax `\\e` is used throughout ' printf "Escape codes begin with \`\\e\`, \`\\033\`, or \`\\x1b\`. These are all three different escape sequences which insert the ASCII character 27, or ESC. (This is why they're called ANSI \"escape\" codes, because they begin with a literal escape character). The syntax \`\\e\` is used throughout "
thebookofcolors thebookofcolors
printf '. The choice is arbitrary, but consistent throughout.\n' printf ". The choice is arbitrary, but consistent throughout.\n"
printf 'The next character is a `[`. This combination of characters, an escape followed by an open bracket, is called the "CSI", or "Control Sequence Introducer", which indicates the start of a control code.\n' printf "The next character is a \`[\`. This combination of characters, an escape followed by an open bracket, is called the \"CSI\", or \"Control Sequence Introducer\", which indicates the start of a control code.\n"
newline newline
printf 'Overall, a control sequence is formatted like so:\n' printf "Overall, a control sequence is formatted like so:\n"
newline newline
printf '\e[3m0x1B + [ + <zero or more numbers, separated by semicolons> + <a letter>\e[0m\n' printf "\e[3m0x1B + [ + <zero or more numbers, separated by semicolons> + <a letter>\e[0m\n"
newline newline
printf 'The CSI sequence we''ve gone over already. The easiest way to think about this is that the letter is the name of a function, and the semicolon-delimited numbers are the arguments to said function.\n' printf "The CSI sequence we've gone over already. The easiest way to think about this is that the letter is the name of a function, and the semicolon-delimited numbers are the arguments to said function.\n"
printf 'By this model of thinking about escape sequences like function calls means you would read "\\e[0;1;34m" as m(0, 1, 34), and "\\e[A" as A().\n' printf "By this model of thinking about escape sequences like function calls means you would read \"\\e[0;1;34m\" as m(0, 1, 34), and \"\\e[A\" as A().\n"
newline newline
printf 'The "m" function is the one we''re interested in. This is the "SGR", or "Select Graphics Rendition", code, and it tells the terminal to activate color and other text effects, which is what we''re interested in.\n' printf "The \"m\" function is the one we're interested in. This is the \"SGR\", or \"Select Graphics Rendition\", code, and it tells the terminal to activate color and other text effects, which is what we're interested in.\n"
} }
section_regular_colors() { section_regular_colors() {
title "Codes 30-37; Regular Foreground Colors" title "Codes 30-37; Regular Foreground Colors"
printf 'Originally, hardware video terminals only had support for eight standard colors.\n' printf "Originally, hardware video terminals only had support for eight standard colors.\n"
printf 'The SGR control codes 30 through 37 are used to set the foreground color to each of these colors.\n' printf "The SGR control codes 30 through 37 are used to set the foreground color to each of these colors.\n"
printf 'These colors and their respective escape codes are shown in the following table:\n' printf "These colors and their respective escape codes are shown in the following table:\n"
newline newline
printf '\e[30m\\e[30m Black\e[0m\n' printf "\e[30m\\e[30m Black\e[0m\n"
printf '\e[31m\\e[31m Red\e[0m\n' printf "\e[31m\\e[31m Red\e[0m\n"
printf '\e[32m\\e[32m Green\e[0m\n' printf "\e[32m\\e[32m Green\e[0m\n"
printf '\e[33m\\e[33m Brown\e[0m\n' printf "\e[33m\\e[33m Brown\e[0m\n"
printf '\e[34m\\e[34m Blue\e[0m\n' printf "\e[34m\\e[34m Blue\e[0m\n"
printf '\e[35m\\e[35m Purple\e[0m\n' printf "\e[35m\\e[35m Purple\e[0m\n"
printf '\e[36m\\e[36m Cyan\e[0m\n' printf "\e[36m\\e[36m Cyan\e[0m\n"
printf '\e[37m\\e[37m Light grey\e[0m\n' printf "\e[37m\\e[37m Light grey\e[0m\n"
} }
section_notes_on_names() { section_notes_on_names() {