tCreate a non-existing directory and test a few things - monochromatic - monochromatic blog: http://blog.z3bra.org
HTML git clone git://z3bra.org/monochromatic
DIR Log
DIR Files
DIR Refs
---
DIR commit 343fdb10c42faa707c2628b1d4849a3ee7cb84bd
DIR parent cfa9f5529f6adcdad9081597441bb6ea62701dc3
HTML Author: Willy Goiffon <w.goiffon@gmail.com>
Date: Sun, 8 Sep 2013 22:59:52 +0200
Create a non-existing directory and test a few things
Diffstat:
M tools/post.sh | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
DIR diff --git a/tools/post.sh b/tools/post.sh
t@@ -2,10 +2,17 @@
[[ -z "$1" ]] && exit 1
-POST="$(date +%Y)/$(date +%m)/${1// /-}.html"
+folder=$(date +%Y/%m)
+file=${1// /-}.html
+
+[[ ! -d ${folder} ]] && mkdir ${folder}
+
+POST="${folder}/${file}"
cat tools/{head,body,foot}.template >> $POST
-echo "$POST created"
+[[ -f ${folder}/${file} ]] && echo "$POST created" && exit 0
+
+echo "cannot create ${POST}"