Skip to content

Commit 1579534

Browse files
committed
Prevent clean_plugins from deleting root
If tmux was not yet configured to initialize the Tmux Plugin Manager, the variable for the plugin home was not being set. This was resulting in a `rm -rf /` which is pretty nuclear. Fixes: tmux-plugins#58
1 parent cfaf15b commit 1579534

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

scripts/helpers/plugin_functions.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,22 @@ _sourced_files() {
3131
awk '/^[ \t]*source(-file)? +/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $2 }'
3232
}
3333

34+
# Want to be able to abort in certain cases
35+
trap "exit 1" TERM
36+
export TOP_PID=$$
37+
38+
_fatal_error_abort() {
39+
echo >&2 "Aborting."
40+
kill -s TERM $TOP_PID
41+
}
42+
3443
# PUBLIC FUNCTIONS BELOW
3544

3645
tpm_path() {
46+
if [ "$_CACHED_TPM_PATH" == "/" ]; then
47+
echo >&2 "FATAL: Tmux Plugin Manager not configured in tmux.conf"
48+
_fatal_error_abort
49+
fi
3750
echo "$_CACHED_TPM_PATH"
3851
}
3952

scripts/update_plugin.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ update_plugins() {
6060
}
6161

6262
main() {
63+
ensure_tpm_path_exists
6364
if [ "$1" == "all" ]; then
6465
update_all
6566
else

0 commit comments

Comments
 (0)