Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in subst: If a \[ follows a $, variables stop being interpolated #296

Closed
jrpat opened this issue Feb 14, 2024 · 1 comment
Closed

Bug in subst: If a \[ follows a $, variables stop being interpolated #296

jrpat opened this issue Feb 14, 2024 · 1 comment

Comments

@jrpat
Copy link

jrpat commented Feb 14, 2024

Admittedly obscure, but it bit me today.

Example jimsh repl session (with notes and newlines added for readability):

Welcome to Jim version 0.82
. set x 123
123

. subst {$\[foo] $x}
$[foo] $x                       ← error - simplest case

. subst {\[foo] $x}
[foo] 123                       ← ok - no dollar sign

. subst {$ \[foo] $x}
$ [foo] $x                      ← error - space after dollar sign

. subst {$  \[foo] $x}
$  [foo] $x                     ← error  - multiple spaces after dollar sign

. puts "$\[foo] $x"
$[foo] 123                      ← ok  - string interpolation works

. set y 789
789

. subst {$\[foo] $x $y}
$[foo] $x $y                    ← error - multiple variables

. subst {$\[foo] ${x} ${y}}
$[foo] ${x} ${y}                ← error - bracing variable names doesn't help

. subst {$\[foo]
{> $x
{> $y
{> }
$[foo]
$x
$y                              ← error - multiple lines

. subst {\$\[foo] $x}
$[foo] 123                      ← ok  - escaping dollar sign

. subst {$x $y $\[foo] $x $y}
123 789 $[foo] $x $y            ← error - following variables don't interpolate

The same session in tclsh:

% set x 123
123

% subst {$\[foo] $x}
$[foo] 123

% subst {\[foo] $x}
[foo] 123

… further examples show correct output …

I 💜 Jim! Thanks again for all your work on it.

@msteveb
Copy link
Owner

msteveb commented Feb 14, 2024

Thanks for the report. Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants