diff --git a/README.md b/README.md index 40c818c..e3e4617 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ align="center">A collection of pure POSIX sh alternatives to external processes. * [Loop over a variable range of numbers](#loop-over-a-variable-range-of-numbers) * [Loop over the contents of a file](#loop-over-the-contents-of-a-file) * [Loop over files and directories](#loop-over-files-and-directories) +* [VARIABLES](#variables) + * [Name a variable based on another variable](#name-a-variable-based-on-another-variable) * [ESCAPE SEQUENCES](#escape-sequences) * [Text Colors](#text-colors) * [Text Attributes](#text-attributes) @@ -559,6 +561,17 @@ for dir in ~/Downloads/*/; do done ``` +# VARIABLES + +## Name a variable based on another variable + +```shell +$ var="world" +$ export "hello_$var=value" +$ printf '%s\n' "$hello_world" +value +``` + # ESCAPE SEQUENCES Contrary to popular belief, there is no issue in utilizing raw escape sequences. Using `tput` abstracts the same ANSI sequences as if printed manually. Worse still, `tput` is not actually portable. There are a number of `tput` variants each with different commands and syntaxes (*try `tput setaf 3` on a FreeBSD system*). Raw sequences are fine.