fix: check only the first string token when searching lsattr

This commit is contained in:
qoijjj
2024-08-10 03:56:35 -07:00
committed by GitHub
parent 872cb784ef
commit 3b927dc8ed

View File

@@ -274,7 +274,7 @@ toggle-bash-environment-lockdown:
echo "Please type in \"YES I UNDERSTAND\" and press enter"
read ACCEPT
if [ "$ACCEPT" == "YES I UNDERSTAND" ]; then
if lsattr "${BASH_ENV_FILES[0]}" 2>/dev/null | grep -q 'i'; then
if lsattr "${BASH_ENV_FILES[0]}" 2>/dev/null | awk '{print $1}' | grep -q 'i'; then
echo "Bash environment '(${BASH_ENV_FILES[@]})' is locked down. Unlocking it."
for file in "${BASH_ENV_FILES[@]}"; do
pkexec chattr -i "$file"