Why does ls show wrong permissions for the group when using ACL?
Solution 1:
If ACL is present, ls -l
signals that with a +
at the end of the permission column. Additionally it doesn't show the group permissions but the mask instead, see this example:
$ getfacl file
user::rw-
user:user:---
group::---
group:group:---
mask::rwx
other::---
$ ls -l file
-rw-rwx---+ 1 user group 0 2010-01-01 00:00 file
Source: https://wiki.ubuntuusers.de/ACL/
Besides your script can be largely simplified, see this pastie, tested with shellcheck.net.