Tcl Source Code

View Ticket
Login
Ticket UUID: 627552
Title: bad pipe error message
Type: Bug Created on: 2002-10-23 15:43:11
Submitter: nobody Assigned to: andreas_kupries
Subsystem: 25. Channel System Severity:
Priority: 5 Medium Last modified: 2026-10-22 17:19:29
Status: Closed Closed by: serhiy.storchaka
Resolution: Fixed Closed on: 2026-10-21 09:58:25
Version: obsolete: 8.4.0
Description:
tclpipe.c
FileForRedirect

<@ channel-without-handle


        chan = Tcl_GetChannel(interp, spec, NULL);
        if (chan == (Tcl_Channel) NULL) {
            return NULL;
        }
file = TclpMakeFile(chan, writing ? TCL_WRITABLE :
TCL_READABLE);
        if (file == NULL) {
            Tcl_AppendResult(interp, "channel \"",
Tcl_GetChannelName(chan),
                    "\" wasn't opened for ",
                    ((writing) ? "writing" :
"reading"), (char *) NULL);
            return NULL;
        }

on unix  TclpMakeFile will return nil if the channel
has no handle
and not just bcause it wasnt readable
leading an incorrect and very confusing error message

the code should be something closer to

       chan = Tcl_GetChannel(interp, spec, &mode);
      if (!((writing ? TCL_WRITABLE :
TCL_READABLE)&mood)) {
              Tcl_AppendResult(interp, "channel \"",
Tcl_GetChannelName(chan),
                    "\" wasn't opened for ",
                    ((writing) ? "writing" :
"reading"), (char *) NULL);
            return NULL;
    }
file = TclpMakeFile(chan, writing ? TCL_WRITABLE :
TCL_READABLE);
        if (file == NULL) {
            Tcl_AppendResult(interp, "channel \"",
Tcl_GetChannelName(chan),
                    "\"  some kind of message about
pipe cant deal with this kind of channel", (char *) NULL);
            return NULL;
        }
User Comments:
serhiy.storchaka added on 2026-10-21 09:58:25:

Fixed in 8.5.8 and 8.6.0 by [9039eeb584] (8.5: [62c8e5320a]): a redirection from or to a channel without an OS handle now reports channel "x" does not support OS handles. See also [1106853fff].