String interpolation in the short-hand call of macro @bash1_str

Hello everyone,
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"
The string FD is interpolated. But if I use the shorthand call
bash1"mkdir $FD"
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 bash.

2 Likes

thanks Tamas, I think this macro is not necessary.