Diff
1diff --git a/lib/cli.zsh b/lib/cli.zsh
2index b71f6d9cee6314195288855e130bdc23265118a1..db659c11fee153debee82fd26bb82af84e1d1ecd 100644
3--- a/lib/cli.zsh
4+++ b/lib/cli.zsh
5@@ -280,9 +280,10 @@ multi == 1 && length(\$0) > 0 {
6 "
7
8 local zdot="${ZDOTDIR:-$HOME}"
9- awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
10- && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
11- && command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
12+ local zshrc="${${:-"${zdot}/.zshrc"}:A}"
13+ awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
14+ && command cp -f "$zshrc" "$zdot/.zshrc.bck" \
15+ && command mv -f "$zdot/.zshrc.new" "$zshrc"
16
17 # Exit if the new .zshrc file wasn't created correctly
18 [[ $? -eq 0 ]] || {
19@@ -294,8 +295,7 @@ multi == 1 && length(\$0) > 0 {
20 # Exit if the new .zshrc file has syntax errors
21 if ! command zsh -n "$zdot/.zshrc"; then
22 _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
23- command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
24- command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
25+ command mv -f "$zdot/.zshrc.bck" "$zshrc"
26 return 1
27 fi
28
29@@ -354,9 +354,10 @@ multi == 1 && /^[^#]*\)/ {
30 "
31
32 local zdot="${ZDOTDIR:-$HOME}"
33- awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
34- && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
35- && command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
36+ local zshrc="${${:-"${zdot}/.zshrc"}:A}"
37+ awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
38+ && command cp -f "$zshrc" "$zdot/.zshrc.bck" \
39+ && command mv -f "$zdot/.zshrc.new" "$zshrc"
40
41 # Exit if the new .zshrc file wasn't created correctly
42 [[ $? -eq 0 ]] || {
43@@ -368,8 +369,7 @@ multi == 1 && /^[^#]*\)/ {
44 # Exit if the new .zshrc file has syntax errors
45 if ! command zsh -n "$zdot/.zshrc"; then
46 _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
47- command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
48- command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
49+ command mv -f "$zdot/.zshrc.bck" "$zshrc"
50 return 1
51 fi
52
53@@ -715,7 +715,8 @@ END {
54 '
55
56 local zdot="${ZDOTDIR:-$HOME}"
57- awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
58+ local zshrc="${${:-"${zdot}/.zshrc"}:A}"
59+ awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
60 || {
61 # Prepend ZSH_THEME= line to .zshrc if it doesn't exist
62 cat <<EOF
63@@ -724,8 +725,8 @@ ZSH_THEME="$1" # set by \`omz\`
64 EOF
65 cat "$zdot/.zshrc"
66 } > "$zdot/.zshrc.new" \
67- && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
68- && command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
69+ && command cp -f "$zshrc" "$zdot/.zshrc.bck" \
70+ && command mv -f "$zdot/.zshrc.new" "$zshrc"
71
72 # Exit if the new .zshrc file wasn't created correctly
73 [[ $? -eq 0 ]] || {
74@@ -737,8 +738,7 @@ EOF
75 # Exit if the new .zshrc file has syntax errors
76 if ! command zsh -n "$zdot/.zshrc"; then
77 _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
78- command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
79- command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
80+ command mv -f "$zdot/.zshrc.bck" "$zshrc"
81 return 1
82 fi
83