comparison bin/example/self-writing.sh @ 327:59f402cd9d98

get mode dynamically
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 08 Jun 2013 08:51:52 -0700
parents dbb6ef0c9a26
children 5de727eb5dc0
comparison
equal deleted inserted replaced
326:dbb6ef0c9a26 327:59f402cd9d98
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 --mode 0755` 8 mode=`stat --format '%a' ${path}`
9 tmp=`tempfile --mode ${mode}`
9 datestamp=`date` 10 datestamp=`date`
10 nonce="This script last generated at " 11 nonce="This script last generated at "
11 12
12 # sanity check 13 # sanity check
13 if [[ ! -w "${path}" ]] 14 if [[ ! -w "${path}" ]]