In the code, you're setting locale variables, e.g.: LANG=C.UTF-8 dpkg-query --search "$path" 2>/dev/null
I can't work out why this would be needed. What are you trying to change the behavior of here? LC_TYPE? LC_COLLATE? LC_MESSAGES?
In any case, there are several environment variables that take precedence over this setting, so it is probably not actually what you want.
In the code, you're setting locale variables, e.g.:
LANG=C.UTF-8 dpkg-query --search "$path" 2>/dev/null
I can't work out why this would be needed. What are you trying to change the behavior of here? LC_TYPE? LC_COLLATE? LC_MESSAGES?
In any case, there are several environment variables that take precedence over this setting, so it is probably not actually what you want.