comparison 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
comparison
equal deleted inserted replaced
322:19b5bf66ba4e 323:b2924a3ae4f3
7 path=`readlink -f $0` 7 path=`readlink -f $0`
8 tmp=`tempfile` 8 tmp=`tempfile`
9 datestamp=`date` 9 datestamp=`date`
10 nonce="This script regenerated at " 10 nonce="This script regenerated at "
11 11
12 # sanity check
13 if [[ ! -w "${path}" ]]
14 then
15 echo "You don't have write permission for script ${path}"
16 exit 1
17 fi
18
12 # avoiding -i for safety 19 # avoiding -i for safety
13 sed 's/\(echo \"'"${nonce}"'\).*\"/\1'"${datestamp}"'\"/' ${path} > ${tmp} 20 sed 's/\(echo \"'"${nonce}"'\).*\"/\1'"${datestamp}"'\"/' ${path} > ${tmp}
14 21
15 # echo last and current generation times for example 22 # echo last and current generation times for example
16 echo "This script last generated at (None)" 23 echo "This script last generated at (None)"
17 echo "Now: ${datestamp}" 24 echo "Now: ${datestamp}"
25
26 # move tmpfile -> script location via exec