You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wondered if all the source functions that receive a string as a parameter could receive a string format and a variadic string parameters as the fmt standard Go package does.
To do that with script you have to execute each subcommand part and do the string interpolation manually.
NOTE this example doesn't illustrate how to handle errors properly to keep it concise.
I'm sure that from the security point of view is NO unless you can guarantee that the value to interpolate comes from a trusted source.
If I'm doing the fmt.Sprintf right now, I'm already committing sins.
Considering that I'm trying to use script for what I was writing before in shell script, I don't see any harm. Obviously, the coder is at the end, who has to be aware and not open security holes.
Do you think that exec(fmt.Sprintf(...)) isn't exactly the right way to do it because of another point of view ?
I wondered if all the source functions that receive a string as a parameter could receive a string format and a variadic string parameters as the fmt standard Go package does.
My use case was the following
To do that with script you have to execute each subcommand part and do the string interpolation manually.
NOTE this example doesn't illustrate how to handle errors properly to keep it concise.
If
Echo
would accept the parameters asfmt.Sprintf
then the last line would be:It doesn't reduce that much the code, but I thought that it shouldn't hurt and in the end, the variadic strings are optional.
My use case was for only the
Echo
function, but I thought that the other source functions could benefit from the same too.The text was updated successfully, but these errors were encountered: