I have variable and its contains of string
LST_FILE='find \"$2\" \"${TYPE[@]}\" \"${NAME[@]}\" -mmin +\"$HOUR_TO_MIN\"'
how to turn related string into command ? is it fine using eval ? or there's any substitute for eval because I've been read that eval is not recommended to use..
eval $LST_FILE
because I plan to do below command,
LST_FILE+='-delete'
eval $LST_FILE
eval
, it is a massive footgun. – Gordon Davisson Aug 15 '21 at 00:57eval
is dangerous in large part because it's misunderstood. It takes the shell's normal parsing process -- which is rather complicated and confusing -- and repeats is, making the whole thing even more complicated and confusing. It can be used safely if you understand shell parsing well, but it tends to get used as a substitute for understanding shell parsing... and doing more of that thing you don't understand is rarely a good idea. (And if you do understand shell parsing well, you usually know of better solutions to whatever problem you're facing.) – Gordon Davisson Aug 15 '21 at 17:29