Skip to content

Commit

Permalink
Use mktemp to create temporary directory and files
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaskanashiro committed Mar 5, 2018
1 parent 63cfb33 commit 9412e8b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ done
###

AW_PATH=$HOME/.vim-anywhere
TMPFILE_DIR=/tmp/vim-anywhere
TMPFILE=$TMPFILE_DIR/doc-$(date +"%y%m%d%H%M%S")
TMPFILE_DIR="$(mktemp -d /tmp/vim-anywhere.XXX)"
TMPFILE_TEMPLATE=doc-$(date +"%y%m%d%H%M%S").XXX
VIM_OPTS=--nofork

# Use ~/.gvimrc.min or ~/.vimrc.min if one exists
Expand All @@ -50,8 +50,14 @@ for vimrc_path in "${VIMRC_PATH[@]}"; do
fi
done

mkdir -p $TMPFILE_DIR
touch $TMPFILE
TMPFILE="$(mktemp -p $TMPFILE_DIR -t $TMPFILE_TEMPLATE)"

function remove_tmp_dir() {
rm -rf $TMPFILE_DIR
}

## Removes all temp files on exit and sigint
trap "remove_tmp_dir" EXIT SIGINT

# Linux
if [[ $OSTYPE == "linux-gnu" ]]; then
Expand Down

0 comments on commit 9412e8b

Please sign in to comment.