On Fri, Jun 03, 2022 at 05:26:22AM -0400, Ionen Wolkens wrote: > On Fri, Jun 03, 2022 at 09:14:05AM +0200, Ulrich Mueller wrote: [...] > > brittle. Also, don't use eval because it is evil. > > This is static evals, they're just evaluating a flat string and it's > no different than.. well just running it as-is except it works around > a noise issue (the 2>/dev/null doesn't register without it). > > eval is mostly evil when it's: > eval "${expanded_variable}=${what_is_this_even}" > > Seeing eval "var=\${not_expanded}" as "evil" makes no sense to me, > it's a harmless warning silencer. I feel this is just overreaction > to the eval keyword (also in other dev ML post). > > To reproduce the warning: > $ var=$(printf "\0") # var=$(<file-with-null-bytes) > bash: warning: command substitution: ignored null byte in input > > doesn't work: var=$(printf "\0") 2>/dev/null > works: eval 'var=$(printf "\0")' 2>/dev/null
Was experimenting for what else works just now. { var=$(printf "\0"); } 2>/dev/null I feel like I remember trying this before for qa-sed but don't remember why I didn't use it (unlike subshells it does keep the var readable). I still don't think that a flat eval was "evil" but if I have a way to avoid it I'll use that instead. -- ionen
signature.asc
Description: PGP signature