comparison bin/example/self-writing.sh @ 325:bc2d0d504270

preserve mode (could, in theory, take from script)
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 08 Jun 2013 08:42:21 -0700
parents ae1346f776c3
children dbb6ef0c9a26
comparison
equal deleted inserted replaced
324:ae1346f776c3 325:bc2d0d504270
3 # illustrate self-writing script (example) 3 # illustrate self-writing script (example)
4 # This one does something hard and replaces dynamic data with sed. 4 # This one does something hard and replaces dynamic data with sed.
5 # Other solutions (magic markers, etc) are possible 5 # Other solutions (magic markers, etc) are possible
6 6
7 path=`readlink -f $0` 7 path=`readlink -f $0`
8 tmp=`tempfile` 8 tmp=`tempfile --mode 0755`
9 datestamp=`date` 9 datestamp=`date`
10 nonce="This script regenerated at " 10 nonce="This script regenerated at "
11 11
12 # sanity check 12 # sanity check
13 if [[ ! -w "${path}" ]] 13 if [[ ! -w "${path}" ]]