I'm using magicsplat in windows which provide a tcl shell as an executable program tclsh.exe.
when using it I accidentally typed h in the shell and get what seems to be a command history list.
Being corious tried to see what command or proc it actually is:
% info procs h
% info commands h
there's no h command or proc, but there's a history command and it seems to produce the same results:
% h
1 h
% history
1 h
2 history
there's no h command or proc, but there's a history command and it seems to produce the same results:
Yes, bug or feature. If it is unique, you can shortcut any command. If
you define a second command starting with h, it will not work any more.
Am 02.04.2022 um 17:59 schrieb pd:
I'm using magicsplat in windows which provide a tcl shell as an
executable program tclsh.exe.
when using it I accidentally typed h in the shell and get what seems
to be a command history list.
Being corious tried to see what command or proc it actually is:
% info procs h
% info commands h
there's no h command or proc, but there's a history command and it
seems to produce the same results:
% h
1 h
% history
1 h
2 history
Yes, bug or feature. If it is unique, you can shortcut any command. If
you define a second command starting with h, it will not work any more.
% h
1 h
% proc help {} {puts help}
% h
ambiguous command name "h": help history
However, it may turn into a real bug as well if you code mostly in an interactive environment and save the final code to a file. When you run
it later as a stand-alone, you may get errors complaining about unknown commands if you have relied on shortened command names. And if you try
to debug it in an interactive shell by loading the same file, the error
may mysteriously vanish. All because of the interactive command
completion feature. It could be quite frustrating the first time you
come across it.
El sábado, 2 de abril de 2022 a las 18:45:49 UTC+2, Harald Oehlmann escribió:
thanks for clarifying , I clearly would put it into the bug bag ;-)there's no h command or proc, but there's a history command and it seems to produce the same results:Yes, bug or feature. If it is unique, you can shortcut any command. If
you define a second command starting with h, it will not work any more.
pd <eukelade@gmail.com> wrote:
I'm using magicsplat in windows which provide a tcl shell as an
executable program tclsh.exe.
when using it I accidentally typed h in the shell and get what seems
to be a command history list.
Being corious tried to see what command or proc it actually is:
What do you get if you type "h" in the windows command shell (i.e., not inside the tclsh)?
Tcl's 'shell' includes a wee bit of extra 'magic code' that, when a tcl command named X is not found, the shell attempts to exec a command from
the OS of the same name, and only if that exec fails, does the shell
report 'command not found'.
I suspect you'll find that "h" in the windows command shell gives you
the same output you saw in the tclsh shell.
This would also explain why you could not introspect the 'h' command
from tcl. It was not a tcl command/alias/proc/etc.
I'm using magicsplat in windows which provide a tcl shell as an
executable program tclsh.exe.
when using it I accidentally typed h in the shell and get what seems
to be a command history list.
Being corious tried to see what command or proc it actually is:
Yes, bug or feature. If it is unique, you can shortcut any command. Ifthanks for clarifying , I clearly would put it into the bug bag ;-)
you define a second command starting with h, it will not work any more. >>
As stated already in this thread, this is not a bug but a feature of interactive shells meant to give the user the power of command
completion (in the same vein as bash). It used to be available only in
wish shells if I am not mistaken but apparently current tclsh shells do
it too.
El sábado, 2 de abril de 2022 a las 23:48:25 UTC+2, saito escribió:prefix, but once determining the command it should be done a complete expansion substituting the prefix command for the full command name. Do it always or never. What is a bug is sometimes you accept a comand prefix ("exapanded") and sometimes you don'
this behaviour is not at all the same as bash , bash does autocompletion based in autoexpand (with tab key) to the exact name. It would be nice tclsh doing the same with a key (tab or other) or automatically assuming the command when using a unique
It works the same way in both bash and wish: if you don't use a tab,
"chm" will give you an error in bash. If you hit the tab key, it will
expand it to "chmod". In wish, if you hit the tab key, it will expand
"h" to "history". Both environments will print a list of options
matching the command prefix you have typed so far.
The only difference I see is that bash will error out if a command
prefix is not expanded; but wish will run it if there is only one
matching target. Otherwise, you get the exact same behavior.
As to why command prefixing/completion does not work when embedded in a deeper level, there is no interactivity there for the user to provide feedback and select an option.
but the tcl_interactive applies to all session or repl, or that should be
% set tcl_interactive
1
% h
1 set tcl_intereractive
2 set tcl_interactive
3 h
% proc p {} { upvar tcl_interactive var; puts "$var"; h }
% p
1
invalid command name "h"
if you set tcl_interactive to 1 that should be applicable to everything you do in the interactive shell, also procs, on the other way there's a high risk to introduce errors that could be hard to identify.
It could be quite frustrating the first time you come across it.
% info [info type $s] $s
my point with this email is not only suggesting possible improvements in handling introspection (or showing my lack of knowledge) but pointing out is should be easier for a user to find about defined symbols in tcl
Am 03.04.22 um 07:46 schrieb Rich:
What do you get if you type "h" in the windows command shell (i.e., not
inside the tclsh)?
No, that idea is wrong. As explained in the rest of the thread, "h"
invokes the Tcl command "history" as it allows any unique abbreviation
if you set interactive mode on.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 494 |
Nodes: | 16 (2 / 14) |
Uptime: | 36:23:19 |
Calls: | 9,741 |
Calls today: | 1 |
Files: | 13,741 |
Messages: | 6,183,473 |