Lazy Evaluation in Bash

Posted by User1 on Stack Overflow See other posts from Stack Overflow or by User1
Published on 2010-05-24T22:16:11Z Indexed on 2010/05/24 22:21 UTC
Read the original article Hit count: 503

Filed under:
|

Is there more elegant way of doing lazy evaluation than the following:

pattern='$x and $y'
x=1
y=2
eval "echo $pattern"

results:

1 and 2

It works but eval "echo ..." just feels sloppy and may be insecure in some way. Is there a better way to do this in Bash?

© Stack Overflow or respective owner

Related posts about bash

Related posts about lazy-evaluation