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
Currently variables can be used in shell macros by using the ($variableName) syntax. For example:
var myString ="hello world"
shell:
echo ($myString )
While this works, it introduces a custom mini-language that you must learn and that is less powerfull than nim's strformat f-string syntax.
I propose to add a way to use the strformat syntax within shell blocks. To do so, we could start a line with a "&" which is an invalid syntax in in Windows cmd.exe as well as in sh, bash and zsh, and has no effect in powershell. When a line started with & the shell macro would call strformat on it and then execute the result in the shell. This would let people use the syntax the already know in their shell blocks. In addition to that it would be much more powerful than the current syntax, since f-strings let you use complex expressions.
With this change the above example could be rewritten as:
var myString ="hello world"
shell:
&echo {myString}
I don't know if we should deprecate the previous syntax. If it was deprecated, a user would be sure that as long as they did not begin a line with a & the command would be sent as is to the shell, which would be nice.
Given that starting a command with a & is basically invalid it probably would not be necessary to handle the case in which the user wanted to execute a command that started with a &. If we cared about that corner case, we could use a double && at the start of a command as a way to escape that initial &.
The text was updated successfully, but these errors were encountered:
Currently variables can be used in shell macros by using the ($variableName) syntax. For example:
While this works, it introduces a custom mini-language that you must learn and that is less powerfull than nim's strformat f-string syntax.
I propose to add a way to use the strformat syntax within shell blocks. To do so, we could start a line with a "&" which is an invalid syntax in in Windows cmd.exe as well as in sh, bash and zsh, and has no effect in powershell. When a line started with & the shell macro would call strformat on it and then execute the result in the shell. This would let people use the syntax the already know in their shell blocks. In addition to that it would be much more powerful than the current syntax, since f-strings let you use complex expressions.
With this change the above example could be rewritten as:
I don't know if we should deprecate the previous syntax. If it was deprecated, a user would be sure that as long as they did not begin a line with a & the command would be sent as is to the shell, which would be nice.
Given that starting a command with a & is basically invalid it probably would not be necessary to handle the case in which the user wanted to execute a command that started with a &. If we cared about that corner case, we could use a double && at the start of a command as a way to escape that initial &.
The text was updated successfully, but these errors were encountered: