for test prefix string (doesnt allow injection of commands), improve printf fmt… | |
git clone git://git.codemadness.org/static-site-scripts | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 501f05e74049ca84d3a314c4e740c0b38671fe60 | |
parent 6f70295baba7ccde865f0913ced236e5d05cc07e | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Sun, 11 Oct 2015 16:54:58 +0200 | |
for test prefix string (doesnt allow injection of commands), improve printf fmt… | |
Diffstat: | |
M generate.sh | 20 ++++++++++---------- | |
1 file changed, 10 insertions(+), 10 deletions(-) | |
--- | |
diff --git a/generate.sh b/generate.sh | |
@@ -74,21 +74,21 @@ pageread() { | |
dateupdated=$(printf '%s' "${timeupdated}" | cut -b 1-10) | |
# if ${id} is empty and title is set: create id based on title. | |
- if [ "${id}" = "" ] && [ ! "${title}" = "" ]; then | |
+ if [ x"${id}" = x"" ] && [ ! x"${title}" = x"" ]; then | |
id=$(makeid "${title}") | |
fi | |
- if [ "${id}" = "" ]; then | |
- printf '%s\n' "Warning: \$id or \$title not set in \"${meta}\"… | |
- continue | |
+ if [ x"${id}" = x"" ]; then | |
+ printf 'Warning: $id or $title not set in "%s", skipping...\n'… | |
+ return | |
fi | |
- if [ "${url}" = "" ]; then | |
+ if [ x"${url}" = x"" ]; then | |
url="${id}.html" | |
fi | |
outfile="${id}.html" | |
urlfull="${siteurlfull}/${outfile}" | |
filename="" | |
# ${content} not set; try data from filetypes. | |
- if [ "${content}" = "" ]; then | |
+ if [ x"${content}" = x"" ]; then | |
if [ -f "${pagesdir}/${basename}.html" ]; then | |
filename="${pagesdir}/${basename}.html" | |
content=$(cat "${filename}") | |
@@ -98,14 +98,14 @@ pageread() { | |
fi | |
fi | |
created="<strong>Created on:</strong> ${datecreated}<br/>" | |
- if [ ! "${datecreated}" = "${dateupdated}" ]; then | |
+ if [ ! x"${datecreated}" = x"${dateupdated}" ]; then | |
created="${created}<strong>Last update on:</strong> ${dateupda… | |
fi | |
} | |
pageheader() { | |
# prefix page title with site title, make sure its neatly formatted. | |
- if [ "${title}" = "" ]; then | |
+ if [ x"${title}" = x"" ]; then | |
pagetitle="${sitetitle}" | |
else | |
pagetitle="${title} - ${sitetitle}" | |
@@ -169,12 +169,12 @@ pagefooter() { | |
} | |
if [ ! -d "${pagesdir}" ]; then | |
- printf '%s\n' "Error: pages directory \"${pagesdir}\" not found." >&2 | |
+ printf 'Error: pages directory "%s" not found.\n' "${pagesdir}" >&2 | |
exit 1 | |
fi | |
# process single page as argument (handy for testing a single page). | |
-if [ ! "$1" = "" ]; then | |
+if [ ! x"$1" = x"" ]; then | |
pagereset | |
pageread "$1" | |
pagecontent |