lib/lib.sh: Sanitize the tag when making a temporary directory.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 22 Dec 2015 21:24:23 +0000 (21:24 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 22 Dec 2015 21:24:23 +0000 (21:24 +0000)
The configuration-file reader is terrible and doesn't cope with values
which contain `#'.

lib/lib.sh

index 467f1ca..dd85bbf 100644 (file)
@@ -15,10 +15,12 @@ run_as_user () {
   PATH=$home/bin:/usr/local/bin:/bin:/usr/bin; export PATH
 }
 
+sanitize () { echo "$1" | tr -c 'A-Za-z0-9-\n' _; }
+
 prepare_tmp () {
   tag=$1
 
-  tmp=$home/tmp/$tag.$$
+  tmp=$home/tmp/$(sanitize "$tag").$$
   rm -rf $tmp
   mkdir $tmp
   trap 'cd $home; rm -rf $tmp' EXIT INT TERM