krieselreihe / litr

Litr (Language Independent Task Runner) lets you configure and then run any tasks you want for any language.
MIT License
8 stars 0 forks source link

How to handle variables inside scripts #5

Closed MartinHelmut closed 3 years ago

MartinHelmut commented 3 years ago

As seen in https://github.com/krieselreihe/litr/wiki/Setup#example variables can be used with ${...} inside scripts

Open questions

MartinHelmut commented 3 years ago

Using environment variables

Cons

Pros

Using the ${} syntax

Cons

Pros

MartinHelmut commented 3 years ago

Issue

The ${} syntax will conflict with regular bash syntax, e.g. echo "${something}", making parsing harder. Also, it will not be possible to guess the user intend, if this should be an environment variable or a Litr variable. A different syntax is needed.

Solution

Use %{} syntax. This does not interfere with existing Bash syntax, can be echoed in or outside a string, but is still familiar inside the general topic of string interpolation.

To escape this sequence use \%{}.