diff bin/example/self-writing.sh @ 323:b2924a3ae4f3

fleshing
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 08 Jun 2013 08:30:37 -0700
parents 19b5bf66ba4e
children ae1346f776c3
line wrap: on
line diff
--- a/bin/example/self-writing.sh	Sat Jun 08 08:28:13 2013 -0700
+++ b/bin/example/self-writing.sh	Sat Jun 08 08:30:37 2013 -0700
@@ -9,9 +9,18 @@
 datestamp=`date`
 nonce="This script regenerated at "
 
+# sanity check
+if [[ ! -w "${path}" ]]
+then
+    echo "You don't have write permission for script ${path}"
+    exit 1
+fi
+
 # avoiding -i for safety
 sed 's/\(echo \"'"${nonce}"'\).*\"/\1'"${datestamp}"'\"/' ${path} > ${tmp}
 
 # echo last and current generation times for example
 echo "This script last generated at (None)"
-echo "Now: ${datestamp}"
\ No newline at end of file
+echo "Now: ${datestamp}"
+
+# move tmpfile -> script location via exec
\ No newline at end of file