3 ms·
But that won't work if I am using variables correct? because {} does not interpolate.
by celeritascelery 5y ago
But that won't work if I am using variables correct? because {} does not interpolate.
- theamk 5y agosure it will, "uplevel" will interpolate for you. There is a link to online playground, I encourage you to visit it and try various changes. No installation or signin required.
- celeritascelery 5y agoI stand corrected, it works just as you describe.
- blacksqr 5y agoIt will work because the value passed to proc multiline within the curly braces is treated as a string without substitutions, that value is then passed to the regsub command which replaces all newlines in the string with spaces, then the result is passed to uplevel, which is basically "eval this string in the scope context where multiline was called". It's uplevel that does all the variable substitution, using any values defined in the scope where multiline was executed.