# HG changeset patch # User Jeff Hammel # Date 1370705437 25200 # Node ID b2924a3ae4f36ca2cc97bb8948251407242b18ff # Parent 19b5bf66ba4e44ecbffb046928d79d02f25c5e5d fleshing diff -r 19b5bf66ba4e -r b2924a3ae4f3 bin/example/self-writing.sh --- 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