Skip to content

Commit

Permalink
Remove unneeded mktemp usage and default to /tmp
Browse files Browse the repository at this point in the history
The current usage is incompatible with GNU mktemp, and is also
unnecessary, as it does not leverage the XXXXXX mechanism to avoid
conflicts.

Also, $TMPDIR is usually not set on linux distributions, in which case
/tmp should be used by default.
  • Loading branch information
ifreund committed Feb 22, 2020
1 parent d55d220 commit 0e647cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions zsh-abbr.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ _zsh_abbr() {
typeset -p ZSH_ABBR_UNIVERSALS > "$ZSH_ABBR_UNIVERSALS_SCRATCH_FILE"

rm "$abbr_universals_updated" 2> /dev/null
mktemp "$abbr_universals_updated" 1> /dev/null
touch "$abbr_universals_updated"
chmod 600 "$abbr_universals_updated"

for abbreviation expansion in ${(kv)ZSH_ABBR_UNIVERSALS}; do
echo "abbr -a -U -- $abbreviation $expansion" >> "$abbr_universals_updated"
Expand Down Expand Up @@ -739,10 +740,11 @@ _zsh_abbr_init() {
fi

# Scratch file
ZSH_ABBR_UNIVERSALS_SCRATCH_FILE="${TMPDIR}/abbr_universals"
ZSH_ABBR_UNIVERSALS_SCRATCH_FILE="${TMPDIR:-/tmp}/abbr_universals"

rm "$ZSH_ABBR_UNIVERSALS_SCRATCH_FILE" 2> /dev/null
mktemp "$ZSH_ABBR_UNIVERSALS_SCRATCH_FILE" 1> /dev/null
touch "$ZSH_ABBR_UNIVERSALS_SCRATCH_FILE"
chmod 600 "$ZSH_ABBR_UNIVERSALS_SCRATCH_FILE"

# Load saved universal abbreviations
if [ -f "$ZSH_ABBR_UNIVERSALS_FILE" ]; then
Expand Down

0 comments on commit 0e647cd

Please sign in to comment.