Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

strin and string

9 views
Skip to first unread message

Bugger.Ankush

unread,
Jun 20, 2011, 3:06:34 AM6/20/11
to
Hi all,

I am just started learning Tcl and may be my question is too much of
an entry level. But it shall be really helpful if some one can clarify
this behavior of Tcl.

strin and string --> both happens to work in similar fashion. Is there
some internal conversion of command strin to string so as to avoid the
typo by the user ?

CARLO KOKOTH

unread,
Jun 20, 2011, 4:21:20 AM6/20/11
to

This is just a feature of the interactive shell, if the command you
typed does not exist but can be resolved unanimously, you get the
behavior you describe.

Try the following:

1) in interactive session (tclsh, tkcon ...) execute just "strin", you
should get the following:
---
wrong # args: should be "string subcommand ?arg ...?"
---
which shows help text for the "string" command, which is what was
executed

2) try executing script which contains the "strin" command, you should
get something like this:
---
invalid command name "strin"
while executing
"strin"
(file <FILENAME> line ***)
---
which shows that the "strin" command does not exist in reality.

3) use "info command" to search for commands, for example "info comm
s*" gives following output (and shows that subcommands can sometimes
be abbreviated too, but this is not a feature of the shell but of the
respective command, command "info" in this case):
---
socket subst split source switch set scan seek string
---
this is a list of all commands starting with letter s, and "strin" is
not among them

cheers, CK.

Bugger.Ankush

unread,
Jun 20, 2011, 5:46:38 AM6/20/11
to

Thanks a lot. It was really helpful.

I was just wondering how this intelligence will work in case we have
two commands - quiet close in lexicographical order and the typo is
mid-way.

To be more clear:
Say I have a command name "abc" and other as "abd".
I now have a typo "abk". So which one it shall take ?

<May be i need to fiddle more with these commands to learn it..>

Andreas Leitgeb

unread,
Jun 20, 2011, 6:35:07 AM6/20/11
to
Bugger.Ankush <ankus...@gmail.com> wrote:
> I was just wondering how this intelligence will work in case we have
> two commands - quite close in lexicographical order and the typo is
> mid-way.

If the typed prefix doesn't match just one command, but more, then
you'll get an error.
Just try "s" as a command. :-)

By the way, since you use terms like "close" and "mid-way"...
This auto-correction feature is quite simple: it really only
looks for existing commands of which your typed command is a
prefix. It wouldn't correct something like "sting" to "string".

0 new messages