kerframil 1535157341 learn In an (( arithmetic context )), never reference an array subscript dynamically as foo[$bar]. Instead, write foo[bar] for indexed arrays, and any of foo[\$bar], foo['$bar'] or ${foo[$bar]} for associative arrays. Otherwise, the expansion of $bar is repeated and is thus vulnerable to code injection. kerframil 1535157881 forget kerframil 1535157897 learn In an arithmetic context, never reference an array subscript dynamically as foo[$bar]. Instead, write foo[bar] for indexed arrays, and any of foo[\$bar], foo['$bar'] or ${foo[$bar]} for associative arrays. Otherwise, the expansion of bar is repeated and is thus vulnerable to code injection. kerframil 1547038757 forget kerframil 1547038766 learn In an arithmetic context, never reference an array subscript dynamically as foo[$bar]. Instead, write foo[bar] for indexed arrays, and any of foo[\$bar], foo['$bar'] or ${foo[$bar]} for associative arrays. Otherwise, the expansion of bar is repeated and is thus vulnerable to code injection. Bash-5.0 introduced an 'assoc_expand_once' shell option to protect against this issue. kerframil 1564482050 forget kerframil 1564482067 learn In an arithmetic context, never reference an array subscript dynamically as foo[$bar]. Instead, write foo[bar] for indexed arrays, and any of foo[\$bar], foo['$bar'] or ${foo[$bar]} for associative arrays. Otherwise, the expansion of bar is repeated and is thus vulnerable to code injection. See also !assoc_expand_once and https://mywiki.wooledge.org/BashPitfalls#pf45. kerframil 1610835096 forget kerframil 1610835153 learn In an arithmetic context, never specify the array subscript as an expansion in the manner of array[$key]. Instead, write array[key] for indexed arrays and array[\$key] for associative arrays. Otherwise, repeated expansions can occur, potentially leading to code injection. See also !assoc_expand_once and !pf 45. tirnanog 1670935429 forget tirnanog 1670935451 learn In an arithmetic context, never specify the array subscript as an expansion in the manner of array[$key]. Instead, write array[key] for indexed arrays and array[\$key] for associative arrays. Otherwise, repeated expansions can occur, potentially leading to code injection. Alas, as of bash 5.2, the [\$key] method no longer works and should now be avoided to ensure forward tirnanog 1670935481 forget tirnanog 1670935558 learn In an arithmetic context, never specify an array subscript as array[$key] for arbitrary values of $key. Instead, write array[key] for indexed arrays and array[\$key] for associative arrays, to avoid code injection. Alas, as of bash 5.2, the [\$key] method no longer works and should be avoided to ensure forward compatibility. See, also, !pf 45, !pf 62 and !assoc_expand_once.