sukria / Backup-Manager

Versatile yet easy to use command line backup tool for GNU/Linux. Suitable for desktop and servers.
http://www.backup-manager.org/
GNU General Public License v2.0
277 stars 88 forks source link

Update sanitize.sh #140

Open DaveRead opened 1 year ago

DaveRead commented 1 year ago

Errors from expr sometimes occur if environment variables are parsed which contain parentheses.

Instead of testing for non-zero length keys, the test for identifying keys to inspect can use the key length, only checking those that are at least 3 characters long (e.g. might start with BM_).

For example, this environment variable creates the issue:

BASH_FUNC_which%%=() {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}

By checking that the parsed key length is greater than 2, unexpected parsing of the environment is less likely to create spurious error messages.