cygtclsh80.exe does not properly in emacs 19.34.6 *shell* buffer
Selner, Jerrell
jerrell.selner@spirentcom.com
Thu Aug 31 13:45:00 GMT 2000
Perhaps this problem has been fixed in a newer version but I thought that it
would be helpful to report it.
I find the *shell* buffer of emacs the best place to run a shell. All of
the output of commands accumulate in this buffer. I can delete material
that I do not want and keep material that I do. I can do searches and also
selectively transfer material to other buffers. I can save commonly used
commands in emacs registers and insert them when needed. In many ways, the
emacs *shell* buffer is far superior to the WindowsNT cmd window.
When I tried to run cygtclsh80.exe in the *shell* buffer of emacs 19.34.6
(running on Windows NT 4), none of the strings sent by cygtclsh80.exe to
stdout appeared in the *shell* buffer. This included the prompt character
and the results of tcl commands that I typed in. Strings that were sent to
stderr did appear. tclsh83.exe from scriptics had the same problem.
I was able to track the problem down to the following (thank God for open
source) =>
Tcl_Main calls library function isatty to determine if the Tcl shell is
being run from a terminal. If the Tcl shell is being run from within the
emacs *shell* buffer, isatty returns 0. This causes Tcl_Main to initialize
the Tcl standard channels in such a way that strings sent to stdout do not
appear.
My solution: change Tcl_Main such that if the first coommand-line argument
is "-", assume that the Tcl shell is being run from a terminal regardless of
the output of isatty.
void
Tcl_Main(argc, argv, appInitProc)
int argc; /* Number of arguments. */
char **argv; /* Array of argument strings. */
Tcl_AppInitProc *appInitProc;
/* Application-specific initialization
* procedure to call after most
* initialization but before starting to
* execute commands. */
{
Tcl_Obj *prompt1NamePtr = NULL;
Tcl_Obj *prompt2NamePtr = NULL;
Tcl_Obj *resultPtr;
Tcl_Obj *commandPtr = NULL;
char buffer[1000], *args, *fileName, *bytes;
int code, gotPartial, tty, length;
int exitCode = 0;
Tcl_Channel inChannel, outChannel, errChannel;
Tcl_FindExecutable(argv[0]);
interp = Tcl_CreateInterp();
#ifdef TCL_MEM_DEBUG
Tcl_InitMemory(interp);
Tcl_CreateCommand(interp, "checkmem", CheckmemCmd, (ClientData) 0,
(Tcl_CmdDeleteProc *) NULL);
#endif
@ /*
@ * Set the "tcl_interactive" variable.
@ Assume interactive (regardless of output of isatty) if first arg is
"-"
@ */
@ tty = isatty(0);
@ if ((argc >1) && (argv[1][0] == '-') && (argv[1][1] == '\0')) {
@ argc--; /* Delete first argument */
@ argv++;
@ tty = 1;
@ }
@ Tcl_SetVar(interp, "tcl_interactive",
@ ((fileName == NULL) && tty) ? "1" : "0", TCL_GLOBAL_ONLY);
/*
* Make command-line arguments available in the Tcl variables "argc"
* and "argv". If the first argument doesn't start with a "-" then
* strip it off and use it as the name of a script file to process.
*/
fileName = NULL;
if ((argc > 1) && (argv[1][0] != '-')) {
fileName = argv[1];
argc--;
argv++;
}
args = Tcl_Merge(argc-1, argv+1);
Tcl_SetVar(interp, "argv", args, TCL_GLOBAL_ONLY);
ckfree(args);
TclFormatInt(buffer, argc-1);
Tcl_SetVar(interp, "argc", buffer, TCL_GLOBAL_ONLY);
Tcl_SetVar(interp, "argv0", (fileName != NULL) ? fileName : argv[0],
TCL_GLOBAL_ONLY);
More information about the Cygwin
mailing list