Mercurial > hg > config
changeset 321:c64406cdcee1
nearly works
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 08 Jun 2013 08:26:37 -0700 |
parents | 5a0009051b13 |
children | 19b5bf66ba4e |
files | bin/example/self-writing.sh |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/example/self-writing.sh Sat Jun 08 07:33:06 2013 -0700 +++ b/bin/example/self-writing.sh Sat Jun 08 08:26:37 2013 -0700 @@ -1,6 +1,15 @@ #!/bin/bash # illustrate self-writing script (example) +# This one does something hard and replaces dynamic data with sed. +# Other solutions (magic markers, etc) are possible -path=`readlink $0` -tmp=`tempfile` \ No newline at end of file +path=`readlink -f $0` +tmp=`tempfile` +datestamp=`date` +nonce="This script regenerated at " + +# avoiding -i for safety +sed 's/\(echo \"'"${nonce}"'\).*\"/\1'"${datestamp}"'\"/' ${path} > ${tmp} + +echo "This script regenerated at " \ No newline at end of file