andreafabrizi / Dropbox-Uploader

Dropbox Uploader is a BASH script which can be used to upload, download, list or delete files from Dropbox, an online file sharing, synchronization and backup service.
https://www.andreafabrizi.it/2016/01/01/Dropbox-Uploader/
GNU General Public License v3.0
6.56k stars 1.08k forks source link

Create temporary directory using mktemp #511

Closed ghost closed 3 years ago

ghost commented 4 years ago

On some systems, TMP_DIR is not /tmp. Using the mktemp -dcommand to generate it automatically. Temporary files removed by simply removing the $TMP_DIR.

ghost commented 4 years ago

It might also be worthwhile adding code like:

# Make sure it gets removed even if the script exits abnormally.
trap "exit 1"           HUP INT PIPE QUIT TERM
trap 'rm -rf "$TMP_DIR"' EXIT