Skip to content

Commit 814d121

Browse files
committed
fix(temp files): directory path plays nice with macos and linux
1 parent e83f54c commit 814d121

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

zsh-abbr.zsh

+24-24
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ _zsh_abbr() {
117117
fi
118118
else
119119
if $opt_type_global; then
120-
source "${TMPDIR:-/tmp}/zsh-user-global-abbreviations"
120+
source "${TMPDIR:-/tmp/}zsh-user-global-abbreviations"
121121

122122
if (( ${+ZSH_ABBR_USER_GLOBALS[$abbreviation]} )); then
123123
unset "ZSH_ABBR_USER_GLOBALS[${(b)abbreviation}]"
124124
util_sync_user
125125
success=true
126126
fi
127127
else
128-
source "${TMPDIR:-/tmp}/zsh-user-abbreviations"
128+
source "${TMPDIR:-/tmp/}zsh-user-abbreviations"
129129

130130
if (( ${+ZSH_ABBR_USER_COMMANDS[$abbreviation]} )); then
131131
unset "ZSH_ABBR_USER_COMMANDS[${(b)abbreviation}]"
@@ -402,7 +402,7 @@ _zsh_abbr() {
402402
fi
403403
else
404404
if $opt_type_global; then
405-
source "${TMPDIR:-/tmp}/zsh-user-global-abbreviations"
405+
source "${TMPDIR:-/tmp/}zsh-user-global-abbreviations"
406406

407407
if ! (( ${+ZSH_ABBR_USER_GLOBALS[$abbreviation]} )); then
408408
if $opt_dry_run; then
@@ -414,7 +414,7 @@ _zsh_abbr() {
414414
success=true
415415
fi
416416
else
417-
source "${TMPDIR:-/tmp}/zsh-user-abbreviations"
417+
source "${TMPDIR:-/tmp/}zsh-user-abbreviations"
418418

419419
if ! (( ${+ZSH_ABBR_USER_COMMANDS[$abbreviation]} )); then
420420
if $opt_dry_run; then
@@ -544,17 +544,17 @@ _zsh_abbr() {
544544
job=$(_zsh_abbr_job_name)
545545
_zsh_abbr_job_push $job $job_group
546546

547-
user_updated="${TMPDIR:-/tmp}/zsh-user-abbreviations"_updated
547+
user_updated="${TMPDIR:-/tmp/}zsh-user-abbreviations"_updated
548548
rm "$user_updated" 2> /dev/null
549549
touch "$user_updated"
550550
chmod 600 "$user_updated"
551551

552-
typeset -p ZSH_ABBR_USER_GLOBALS > "${TMPDIR:-/tmp}/zsh-user-global-abbreviations"
552+
typeset -p ZSH_ABBR_USER_GLOBALS > "${TMPDIR:-/tmp/}zsh-user-global-abbreviations"
553553
for abbreviation expansion in ${(kv)ZSH_ABBR_USER_GLOBALS}; do
554554
echo "abbr -g ${abbreviation}=${(qqq)${(Q)expansion}}" >> "$user_updated"
555555
done
556556

557-
typeset -p ZSH_ABBR_USER_COMMANDS > "${TMPDIR:-/tmp}/zsh-user-abbreviations"
557+
typeset -p ZSH_ABBR_USER_COMMANDS > "${TMPDIR:-/tmp/}zsh-user-abbreviations"
558558
for abbreviation expansion in ${(kv)ZSH_ABBR_USER_COMMANDS}; do
559559
echo "abbr ${abbreviation}=${(qqq)${(Q)expansion}}" >> "$user_updated"
560560
done
@@ -803,7 +803,7 @@ _zsh_abbr_cmd_expansion() {
803803
expansion="${ZSH_ABBR_SESSION_COMMANDS[$abbreviation]}"
804804

805805
if [[ ! -n "$expansion" ]]; then
806-
source "${TMPDIR:-/tmp}/zsh-user-abbreviations"
806+
source "${TMPDIR:-/tmp/}zsh-user-abbreviations"
807807
expansion="${ZSH_ABBR_USER_COMMANDS[$abbreviation]}"
808808
fi
809809

@@ -834,7 +834,7 @@ _zsh_abbr_global_expansion() {
834834
expansion="${ZSH_ABBR_SESSION_GLOBALS[$abbreviation]}"
835835

836836
if [[ ! -n "$expansion" ]]; then
837-
source "${TMPDIR:-/tmp}/zsh-user-global-abbreviations"
837+
source "${TMPDIR:-/tmp/}zsh-user-global-abbreviations"
838838
expansion="${ZSH_ABBR_USER_GLOBALS[$abbreviation]}"
839839
fi
840840

@@ -867,13 +867,13 @@ _zsh_abbr_init() {
867867
fi
868868

869869
# Scratch files
870-
rm "${TMPDIR:-/tmp}/zsh-user-abbreviations" 2> /dev/null
871-
touch "${TMPDIR:-/tmp}/zsh-user-abbreviations"
872-
chmod 600 "${TMPDIR:-/tmp}/zsh-user-abbreviations"
870+
rm "${TMPDIR:-/tmp/}zsh-user-abbreviations" 2> /dev/null
871+
touch "${TMPDIR:-/tmp/}zsh-user-abbreviations"
872+
chmod 600 "${TMPDIR:-/tmp/}zsh-user-abbreviations"
873873

874-
rm "${TMPDIR:-/tmp}/zsh-user-global-abbreviations" 2> /dev/null
875-
touch "${TMPDIR:-/tmp}/zsh-user-global-abbreviations"
876-
chmod 600 "${TMPDIR:-/tmp}/zsh-user-global-abbreviations"
874+
rm "${TMPDIR:-/tmp/}zsh-user-global-abbreviations" 2> /dev/null
875+
touch "${TMPDIR:-/tmp/}zsh-user-global-abbreviations"
876+
chmod 600 "${TMPDIR:-/tmp/}zsh-user-global-abbreviations"
877877
}
878878

879879
function seed() {
@@ -893,8 +893,8 @@ _zsh_abbr_init() {
893893

894894
unset ZSH_ABBR_NO_SYNC_USER
895895

896-
typeset -p ZSH_ABBR_USER_COMMANDS > "${TMPDIR:-/tmp}/zsh-user-abbreviations"
897-
typeset -p ZSH_ABBR_USER_GLOBALS > "${TMPDIR:-/tmp}/zsh-user-global-abbreviations"
896+
typeset -p ZSH_ABBR_USER_COMMANDS > "${TMPDIR:-/tmp/}zsh-user-abbreviations"
897+
typeset -p ZSH_ABBR_USER_GLOBALS > "${TMPDIR:-/tmp/}zsh-user-global-abbreviations"
898898
}
899899

900900
# open job
@@ -929,16 +929,16 @@ _zsh_abbr_job_push() {
929929
job_group=${(q)2}
930930
timeout_age=30 # seconds
931931

932-
job_dir=${TMPDIR:-/tmp}/zsh-abbr-jobs/${job_group}
932+
job_dir=${TMPDIR:-/tmp/}zsh-abbr-jobs/${job_group}
933933
job_path=$job_dir/$job
934934

935935
function add_job() {
936936
if ! [ -d $job_dir ]; then
937937
mkdir -p $job_dir
938938
fi
939939

940-
if ! [ -d ${TMPDIR:-/tmp}/zsh-abbr-jobs/current ]; then
941-
mkdir ${TMPDIR:-/tmp}/zsh-abbr-jobs/current
940+
if ! [ -d ${TMPDIR:-/tmp/}zsh-abbr-jobs/current ]; then
941+
mkdir ${TMPDIR:-/tmp/}zsh-abbr-jobs/current
942942
fi
943943

944944
echo $job_group > $job_path
@@ -959,7 +959,7 @@ _zsh_abbr_job_push() {
959959
echo
960960

961961
rm $next_job_path &>/dev/null
962-
rm "${TMPDIR:-/tmp}/zsh-abbr-jobs/current/$job_group*" &>/dev/null
962+
rm "${TMPDIR:-/tmp/}zsh-abbr-jobs/current/$job_group*" &>/dev/null
963963
}
964964

965965
function wait_turn() {
@@ -974,7 +974,7 @@ _zsh_abbr_job_push() {
974974
sleep 0.01
975975
done
976976

977-
cp $job_path "${TMPDIR:-/tmp}/zsh-abbr-jobs/current/$job_group-$job"
977+
cp $job_path "${TMPDIR:-/tmp/}zsh-abbr-jobs/current/$job_group-$job"
978978
}
979979

980980
add_job
@@ -996,13 +996,13 @@ _zsh_abbr_job_pop() {
996996
job_group=$2
997997

998998
typeset -a currents
999-
currents=(${(@f)$(ls -d ${TMPDIR:-/tmp}/zsh-abbr-jobs/current/$job_group* 2>/dev/null)})
999+
currents=(${(@f)$(ls -d ${TMPDIR:-/tmp/}zsh-abbr-jobs/current/$job_group* 2>/dev/null)})
10001000

10011001
for current in $currents; do
10021002
rm $current &>/dev/null
10031003
done
10041004

1005-
rm "${TMPDIR:-/tmp}/zsh-abbr-jobs/${job_group}/${job}" &>/dev/null
1005+
rm "${TMPDIR:-/tmp/}zsh-abbr-jobs/${job_group}/${job}" &>/dev/null
10061006
}
10071007

10081008
_zsh_abbr_job_name() {

0 commit comments

Comments
 (0)