ltog/osmi-addresses

Use `mktemp` in scripts

Opened this issue · 1 comments

ltog commented

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

ltog commented

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.