I am trying to improve the following macro:
macro bash1_str(s1) s = eval(s1); println(s); open(bash
,"w",stdout) do io; print(io, s); end; end ;
If I call
@bash1_str "mkdir $FD"
FD is interpolated. But if I use the shorthand call
The interpolation DOES NOT happen. How can I enforce the interpolation in the shorthand call?
Note that your macro appears to have side effects and not an AST transformation, and as such it may not do what you want in general.
That said, non-standard string literals specifically do not perform string interpolation automatically — that’s kind of the point. You could do it manually, but I am not sure why the whole thing isn’t just a function — you could just construct a command to run
thanks Tamas, I think this macro is not necessary.