File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -175,13 +175,15 @@ _encrypt_file () {
175
175
compress_if_text |
176
176
_encrypt " $_plain_path " > " $ENC_REPO /$_enc_path "
177
177
}
178
+ _bind_tty_fd7 () { if [ -e /dev/tty ]; then exec 7< /dev/tty; else exec 7< /dev/null; fi ; } # Fd 7 used in _decrypt_file
178
179
_decrypt_file () {
179
180
_enc_path=" $1 "
180
181
_plain_path=" $2 "
181
182
# Check if the plain file already exists
183
+ [ ! -d " /proc/$$ " ] || [ -e " /proc/$$ /fd/7" ] # Assert fd-7 is available
182
184
if [ -f " $WORK_TREE /$_plain_path " ] && [ -z " ${YES_OVERWRITE:- } " ]; then
183
185
warn " WARNING: File '$WORK_TREE /$_plain_path ' exists. Overwrite? [y/N]"
184
- read _choice
186
+ read _choice < & 7
185
187
case " $_choice " in [Yy]* ) ;; * ) warn " Skipping '$WORK_TREE /$_plain_path '" ; return 0 ;; esac
186
188
fi
187
189
decrypted_tmpfile=" $( _mktemp) "
@@ -306,6 +308,7 @@ cmd_decrypt () {
306
308
fi
307
309
else
308
310
quiet _trap_append " git_enc checkout --force master" INT HUP TERM EXIT
311
+ _bind_tty_fd7
309
312
git_enc rev-list --reverse master |
310
313
while IFS= _read_vars _enc_commit; do
311
314
# shellcheck disable=SC2154
@@ -602,6 +605,7 @@ cmd_checkout() {
602
605
git_enc sparse-checkout reapply
603
606
604
607
_ask_pw
608
+ _bind_tty_fd7
605
609
_parallelize 0 2 _checkout_file < " $working_manifest "
606
610
fi
607
611
}
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ title 'Ensure restoration script is present in the encrypted repo'
77
77
stat " $WORK_TREE /.myba/_encrypted/myba.sh"
78
78
title ' No overwrite existing file unless forced'
79
79
myba checkout " foo/.dotfile"
80
- if myba checkout " foo/.dotfile" ; then exit 2; fi
80
+ if setsid myba checkout " foo/.dotfile" ; then exit 2; fi
81
81
YES_OVERWRITE=1 myba checkout " foo/.dotfile"
82
82
unset YES_OVERWRITE # Fix for buggy macOS shell
83
83
You can’t perform that action at this time.
0 commit comments