当前位置:网站首页>TCL/TK分组和替换规则
TCL/TK分组和替换规则
2022-07-21 11:19:00 【U.2 SSD】
TCL/TK分组和替换规则
Substitution and Grouping Summary
The following rules summarize the fundamental mechanisms of grouping and substitution that are performed by the Tcl interpreter before it invokes a command:
Command arguments are separated by white space, unless arguments are grouped with curly braces or double quotes as described below.
Grouping with curly braces, { }, prevents substitutions. Braces nest. The interpreter includes all characters between the matching left and right brace in the group, including newlines, semicolons, and nested braces. The enclosing (i.e., outermost) braces are not included in the group’s value.
Grouping with double quotes, " ", allows substitutions. The interpreter groups everything until another double quote is found, including newlines and semicolons. The enclosing quotes are not included in the group of characters. A double-quote character can be included in the group by quoting it with a backslash, (e.g., ").
Grouping decisions are made before substitutions are performed, which means that the values of variables or command results do not affect grouping.
A dollar sign, $, causes variable substitution. Variable names can be any length, and case is significant. If variable references are embedded into other strings, or if they include characters other than letters, digits, and the underscore, they can be distinguished with the ${varname} syntax.
Square brackets, [ ], cause command substitution. Everything between the brackets is treated as a command, and everything including the brackets is replaced with the result of the command. Nesting is allowed.
The backslash character, , is used to quote special characters. You can think of this as another form of substitution in which the backslash and the next character or group of characters are replaced with a new character.
Substitutions can occur anywhere unless prevented by curly brace grouping. Part of a group can be a constant string, and other parts of it can be the result of substitutions. Even the command name can be affected by substitutions.
A single round of substitutions is performed before command invocation. The result of a substitution is not interpreted a second time. This rule is important if you have a variable value or a command result that contains special characters such as spaces, dollar signs, square brackets, or braces. Because only a single round of substitution is done, you do not have to worry about special characters in values causing extra substitutions.
边栏推荐
猜你喜欢
随机推荐
Huawei machine test: imitating LISP operation
[39题] 牛客深度学习专项题
ANSVC无功补偿装置助力江苏某环保能源项目
Chapter 97 notes - abstraction in solidity
Learning notes of Stanford CV course (I)
大型体育场馆应急照明设计
Part 103 decimals in compound
(number theory board) sum of divisors and divisors
Multimodal model clip4clip takes you to realize mutual search between text and video
编译原理实验1——词法分析程序设计原理与实现
C语言练习题-结构体与联合体
Calendar常用方法
UVM register model: reg adapter implementation and integration
确保一线施工人员健康安全,深圳建筑工地实行错时施工
IDEA发布可运行的JAR包
Part 98 Truffle
PostgreSQL每周新闻—2022年7月13日
定时任务框架
记一次去除连接数限制问题
MySQL索引原理以及查询优化「建议收藏」