ltog / osmi-addresses

Calculates the Address view of the OSM Inspector
Boost Software License 1.0
11 stars 4 forks source link

Use `mktemp` in scripts #69

Open ltog opened 8 years ago

ltog commented 8 years ago

Creation of temporary files and directories in scripts should be done using mktemp, especially in those using parallel.

ltog commented 8 years ago

Draft to create temporary directory and a temporary file in it:

#!/bin/bash

tmpdir=$(mktemp --tmpdir --directory "$(basename ${0})-XXXXXXXXXX") || {
        echo "ERROR: Could not create temporary directory.";
        cleanup
        exit 1;
}

tmpfile=$(mktemp --tmpdir="$tmpdir" "asdf-XXXXXXXXXXXXXXXXXX") || {
        echo "ERROR: Could not create temporary file.";
        cleanup
        exit 1;
}

echo tmpfile=$tmpfile

Note: The closing curly brace must end on a new line.