Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-12-01
23:56 • Ticket [1076248fff] if command error status still Closed with 4 other change... artifact: bdbb4bb137 user: dgp
23:41 • Ticket [1076248fff]: 4 changes artifact: c00002f1d4 user: dgp
16:09 • Ticket [1076248fff]: 4 changes artifact: 876dd82519 user: dkf
07:06 • Closed ticket [1076248fff]. artifact: 7ebbf21ffe user: hobbs
2004-11-30
20:20 • New ticket [1076248fff]. artifact: 6a05297568 user: nobody

if command error

Closed / Invalid1076248fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2004-11-30 20:20:23
Tested on ActiveTcl build8.4.8 and self-built 8.4.8 on
Red hat 9.0

tclsh
% set test_string "</Config>"
</Config>
% if [ regexp "^</(.*)>" $test_string jerk cfg_line ] {
puts $cfg_line
} elseif [ regexp "^<(.*)>" $test_string jerk cfg_line ] {
}
/Config


% if [ regexp "^</(.*)>" $test_string jerk cfg_line ] {
puts $cfg_line
} elseif [ regexp "^<(.*)>" $test_string jerk cfg_line2 ] {
}
Config
%
hobbsplain2004-12-01 07:06:36
Logged In: YES 
user_id=72656

Pilot error - you must {} exprs, otherwise they are eval'ed
as expected.  In both cases, both regexps are evaled, you
just change the var for the 2nd RE in the 2nd case.
dkfplain2004-12-01 16:09:16
Logged In: YES 
user_id=79902

Elaborating on what Jeff said, you probably meant to say this:
   if {[ regexp "^</(.*)>" $test_string jerk cfg_line ]} {
      puts $cfg_line
   } elseif {[ regexp "^<(.*)>" $test_string jerk cfg_line ]} {
   }
Notice the {} round the invokations of [regexp]? It's
important (and it also helps the code go faster as a bonus.)
dgpplain2004-12-01 23:41:57
Logged In: YES 
user_id=80530

The confusion here arises because
Tcl was apparently buggy in releases
8.0 through 8.3 on this point, and only
in 8.4 did it get corrected.

still looking for the relevant bug report.
dgpplain2004-12-01 23:56:50
Logged In: YES 
user_id=80530

Probably was Bug 219166.
Log in (anonymous is fine) to add a comment.