Fix lsiown edge cases

This commit is contained in:
quietsy
2023-09-14 20:46:44 +03:00
parent 32bfaff024
commit e18e6900db
2 changed files with 9 additions and 1 deletions
+8 -1
View File
@@ -127,8 +127,15 @@ create_lsiown_alias() {
exit 0
fi
ERROR='**** Permissions could not be set. This is probably because your volume mounts are remote or read-only. ****\n**** The app may not work properly and we will not provide support for it. ****\n'
PATH=("${@:2}")
/usr/bin/find "${PATH[@]}" \( ! -group "${GROUP}" -o ! -user "${USER}" \) -exec chown "${OPTIONS[@]}" "${USER}":"${GROUP}" {} + || printf '**** Permissions could not be set. This is probably because your volume mounts are remote or read-only. ****\n**** The app may not work properly and we will not provide support for it. ****\n'
if [[ "${OPTIONS[*]}" =~ "-R" ]]; then
OPTIONS=( "${OPTIONS[@]/-R/-P}" )
/usr/bin/find "${PATH[@]}" \( ! -group "${GROUP}" -o ! -user "${USER}" \) -exec chown "${OPTIONS[@]}" "${USER}":"${GROUP}" {} + || printf "${ERROR}"
else
/usr/bin/find "${PATH[@]}" -maxdepth 0 \( ! -group "${GROUP}" -o ! -user "${USER}" \) -exec chown "${OPTIONS[@]}" "${USER}":"${GROUP}" {} + || printf "${ERROR}"
fi
EOF
chmod +x /usr/bin/lsiown
}