On 1/25/23 03:50, Roberto Sassu wrote:
From: Roberto Sassu <roberto.sassu@xxxxxxxxxx>
+ + last_char=${ima_xattr: -1}
To avoid last_char from spilling into the global variable space I would declare it as local. I would do this for **every** variable. An example from functions.sh: _evmctl_run() { local op=$1 out=$1-$$.out local text_for=${FOR:+for $ADD_TEXT_FOR} # Additional parameters: # ADD_DEL: additional files to rm on failure # ADD_TEXT_FOR: append to text as 'for $ADD_TEXT_FOR' cmd="evmctl $V $EVMCTL_ENGINE $*" echo $YELLOW$TMODE "$cmd"$NORM $cmd >"$out" 2>&1 ret=$? [...] } If I have a function like this here calling _evmctl_run() it will clobber even my local-declared ret and cmd variables because neither is declared as local in _evmctl_run. foo() { local ret=123 local cmd="mycmd" [...] _evmctl_run ... # my ret and cmd are now clobbered! } Stefan