
The code for each module is wrapped in a function so the module can be parameterized, and so its variables can be scoped to the function. However, the function names must be unique, otherwise when the modules are sourced, functions will overwrite functions with the same name in previously sourced modules.
16 lines
330 B
Bash
Executable File
16 lines
330 B
Bash
Executable File
#!/bin/bash
|
|
|
|
mod_dt () {
|
|
# Customizable configuration constants
|
|
local -r DEFAULT_FMT='%a %d %I:%M%p'
|
|
local -r DEFAULT_PRE=''
|
|
local -r DEFAULT_SUF=''
|
|
|
|
local -r fmt="${1:-${DEFAULT_FMT}}"
|
|
local -r pre="${2-${DEFAULT_PRE}}"
|
|
local -r suf="${3-${DEFAULT_SUF}}"
|
|
|
|
printf '%b%b%b' "${pre}" "$(date +"${fmt}")" "${suf}"
|
|
}
|
|
|