This is a little simpler than the docs/cookbook/c project, which doesn't actually have a doc yet because there was too much to explain. I think I might make that a follow-on cookbook chapter, for people who have read this simple one. I think this doc is maybe a little too long; I intended it to be "here's what you do to get started" but it turned into "here's what you do to get started, and why it works, in excruciating detail." Not quite sure how to fix. (Also updated some other parts of the docs to refer to redoconf as a real thing now instead of a "maybe someone should write this" thing.)
25 lines
589 B
Text
25 lines
589 B
Text
. ./redoconf.rc
|
|
|
|
# this is called by each call to replaceln() and appendln().
|
|
RC_KEYS="RC_KEYS"
|
|
rc_hook() {
|
|
contains_line "$RC_KEYS" "$1" || RC_KEYS="$RC_KEYS$NL$1"
|
|
}
|
|
rc_include _all.rc
|
|
|
|
# Escape double-quote and backslash so they can
|
|
# be included as a C-style double-quoted string.
|
|
cquote() {
|
|
local v="$(xecho "$1" | sed -e 's,[\"\\],\\&,g' -e 's,$, \\,')"
|
|
printf '"%s"' "${v% \\}"
|
|
}
|
|
|
|
(
|
|
echo "# Automatically generated by rc_vars.od"
|
|
for k in $(echo "$RC_KEYS" | sort); do
|
|
[ "$k" != "RC_INCLUDES" ] || continue
|
|
eval v=\$$k
|
|
echo "$k=$(shquote "$v")"
|
|
done
|
|
) >$3
|
|
redo-stamp <$3
|