Skip to content

Commit

Permalink
Create temporary file safely using mktemp
Browse files Browse the repository at this point in the history
  • Loading branch information
Strus committed May 1, 2022
1 parent 9a9c82c commit a55f7a5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ done
###

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

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

mkdir -p $TMPFILE_DIR
touch $TMPFILE

# Linux
if [[ $OSTYPE == "linux-gnu" ]]; then
chmod o-r $TMPFILE # Make file only readable by you
Expand Down Expand Up @@ -82,3 +78,5 @@ elif [[ $OSTYPE == "darwin"* ]]; then
LANG=en_US.UTF-8 tr -d '\n' < $TMPFILE | pbcopy
osascript -e "activate application \"$app\""
fi

rm $TMPFILE

0 comments on commit a55f7a5

Please sign in to comment.