• Re: tclsh and cygwin (mobaxterm)

    From pd@21:1/5 to All on Sun Mar 26 07:46:36 2023
    El domingo, 26 de marzo de 2023 a las 16:43:07 UTC+2, pd escribió:

    Any idea or explanation?

    Of course this is just for fun, I'm be curious about this behaviour I cannot explain, please don't loose any time with this, just if you have a free time to waste ;-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From pd@21:1/5 to All on Sun Mar 26 07:43:04 2023
    Hello,

    I have a weird behaviour with tclsh in cygwin (mobaxterm) environment and I really doesn't know why so I'd really appreciate any clue.

    Scenario:

    I've installed magisplat in my windows 10 so I have tclsh available in my path.

    When I open a cmd windows shell I can run tclsh and I get a tcl prompt (%) and command echo:

    tclsh
    %

    % puts "hello"
    hello

    But when I invoke tclsh from a mobaxterm terminal window I get no prompt and a solid squared cursor ([]):

    $ tclsh
    []
    puts "hello"
    hello
    []

    It also seems there's no command echo:

    $ tclsh
    set h hello
    set h
    puts "$h"
    hello
    []

    where it should be:

    $ tclsh
    % set h hello
    hello
    % set h
    hello
    % puts "$h"
    hello

    Also it seems tclsh is treating paths as windows style:

    $ tclsh
    puts "[set auto_path]"
    C:/Apps/Tcl86/lib/tcl8.6 C:/Apps/Tcl86/lib

    when I expect it would use unix like paths

    My assumption:

    I think this weird behaviour may be related to the fact of using a windows program in a "unix" shell environment (cygwin mobaxterm), the tclsh program cygwin is using is the one installed by magicsplat:

    $ which tclsh
    /drives/c/Apps/Tcl86/bin/tclsh

    And so there's a clash between naming conventions, if I create a tcl file just to require package ticklecharts like:

    lappend auto_path "/home/mobaxterm/myDownloads/tcl/ticklecharts-master"
    puts "[set auto_path]"
    package require ticklecharts

    and run it from ticklechars dir:

    $ pwd
    /home/mobaxterm/myDownloads/tcl/ticklecharts-master
    $ tclsh ej.tcl
    C:/Apps/Tcl86/lib/tcl8.6 C:/Apps/Tcl86/lib /home/mobaxterm/myDownloads/tcl/ticklecharts-master
    can't find package ticklecharts
    while executing
    "package require ticklecharts"
    (file "ej.tcl" line 5)

    changing the path to add to auto_path in the file to different values I get:

    - with /drives/c/Users/p/Downloads/tcl/ticklecharts-master
    $ tclsh ej.tcl
    C:/Apps/Tcl86/lib/tcl8.6 C:/Apps/Tcl86/lib /drives/c/Users/p/Downloads/tcl/ticklecharts-master
    can't find package ticklecharts
    while executing
    "package require ticklecharts"
    (file "ej.tcl" line 5)

    - with current dir (.):
    $ tclsh ej.tcl
    C:/Apps/Tcl86/lib/tcl8.6 C:/Apps/Tcl86/lib .
    html:.\render.html

    - with current dir as windows style path:
    $ tclsh ej.tcl
    C:/Apps/Tcl86/lib/tcl8.6 C:/Apps/Tcl86/lib {C:\Users\p\Downloads\tcl\ticklecharts-master}
    html:.\render.html

    So it reckonizes windows style paths only

    Maybe this is the reason of weird behaviour too, a kind of clash with internal paths or files o even pipes.

    Probably the solution is to install tcl from cygwin itself, but I really don't understand why it behaves so weird.

    Of course If I execute tclsh from cygwin through cmd.exe everything goes ok:

    $ cmd.exe /c tclsh.exe
    % set h hello
    hello
    % set h
    hello


    Any idea or explanation?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to eukelade@gmail.com on Sun Mar 26 15:39:50 2023
    pd <eukelade@gmail.com> wrote:
    I think this weird behaviour may be related to the fact of using a
    windows program in a "unix" shell environment (cygwin mobaxterm), the
    tclsh program cygwin is using is the one installed by magicsplat:

    It is. Windows is very different internally from Unix (even if MS
    claims and/or got is certified as 'posix' compatible) and you will find
    lots of little tidbits like this where square pegs just don't fit
    properly into round holes. At the Tcl script level the Tcl runtime
    papers over the differences so the script see's little of them. But at
    the interface just outside the runtime to the rest of the environment
    you are at the mercy of whatever is handling that (in your case the
    cygwin runtime).

    Another one that can be very irritating when one uses "puts stderr"
    debugging sometimes is that pure GUI programs don't have a
    stdin/stderr/stdout IO channel available.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From briang@21:1/5 to Rich on Sun Mar 26 15:35:55 2023
    On Sunday, March 26, 2023 at 8:39:53 AM UTC-7, Rich wrote:
    pd <euke...@gmail.com> wrote:
    I think this weird behaviour may be related to the fact of using a
    windows program in a "unix" shell environment (cygwin mobaxterm), the tclsh program cygwin is using is the one installed by magicsplat:
    It is. Windows is very different internally from Unix (even if MS
    claims and/or got is certified as 'posix' compatible) and you will find
    lots of little tidbits like this where square pegs just don't fit
    properly into round holes. At the Tcl script level the Tcl runtime
    papers over the differences so the script see's little of them. But at
    the interface just outside the runtime to the rest of the environment
    you are at the mercy of whatever is handling that (in your case the
    cygwin runtime).

    Another one that can be very irritating when one uses "puts stderr" debugging sometimes is that pure GUI programs don't have a stdin/stderr/stdout IO channel available.

    The specific problem here is the "isatty()" posix function. This function does not work correctly in a Windows Console. This function is only used when Tclsh is built for "unix". The Windows build does not use this function. Instead, tclsh is built as
    a Console Application which guarantees a Windows console is present, and tclsh operates accordingly.

    Since the "unix" build uses isatty(), and this function always returns "false" on Windows, tclsh does not enable interactive mode, which disables the prompt. If you type in: set tcl_interactive 1, then the prompt will appear.

    -Brian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Mon Mar 27 08:18:37 2023
    Am 26.03.2023 um 16:43 schrieb pd:
    Hello,

    I have a weird behaviour with tclsh in cygwin (mobaxterm) environment and I really doesn't know why so I'd really appreciate any clue.

    Scenario:

    I've installed magisplat in my windows 10 so I have tclsh available in my path.

    When I open a cmd windows shell I can run tclsh and I get a tcl prompt (%) and command echo:

    tclsh
    %

    % puts "hello"
    hello

    But when I invoke tclsh from a mobaxterm terminal window I get no prompt and a solid squared cursor ([]):

    $ tclsh
    []
    puts "hello"
    hello
    []

    It also seems there's no command echo:

    $ tclsh
    set h hello
    set h
    puts "$h"
    hello
    []

    where it should be:

    $ tclsh
    % set h hello
    hello
    % set h
    hello
    % puts "$h"
    hello

    Also it seems tclsh is treating paths as windows style:

    $ tclsh
    puts "[set auto_path]"
    C:/Apps/Tcl86/lib/tcl8.6 C:/Apps/Tcl86/lib

    when I expect it would use unix like paths

    My assumption:

    I think this weird behaviour may be related to the fact of using a windows program in a "unix" shell environment (cygwin mobaxterm), the tclsh program cygwin is using is the one installed by magicsplat:

    $ which tclsh
    /drives/c/Apps/Tcl86/bin/tclsh

    And so there's a clash between naming conventions, if I create a tcl file just to require package ticklecharts like:

    lappend auto_path "/home/mobaxterm/myDownloads/tcl/ticklecharts-master"
    puts "[set auto_path]"
    package require ticklecharts

    and run it from ticklechars dir:

    $ pwd
    /home/mobaxterm/myDownloads/tcl/ticklecharts-master
    $ tclsh ej.tcl
    C:/Apps/Tcl86/lib/tcl8.6 C:/Apps/Tcl86/lib /home/mobaxterm/myDownloads/tcl/ticklecharts-master
    can't find package ticklecharts
    while executing
    "package require ticklecharts"
    (file "ej.tcl" line 5)

    changing the path to add to auto_path in the file to different values I get:

    - with /drives/c/Users/p/Downloads/tcl/ticklecharts-master
    $ tclsh ej.tcl
    C:/Apps/Tcl86/lib/tcl8.6 C:/Apps/Tcl86/lib /drives/c/Users/p/Downloads/tcl/ticklecharts-master
    can't find package ticklecharts
    while executing
    "package require ticklecharts"
    (file "ej.tcl" line 5)

    - with current dir (.):
    $ tclsh ej.tcl
    C:/Apps/Tcl86/lib/tcl8.6 C:/Apps/Tcl86/lib .
    html:.\render.html

    - with current dir as windows style path:
    $ tclsh ej.tcl
    C:/Apps/Tcl86/lib/tcl8.6 C:/Apps/Tcl86/lib {C:\Users\p\Downloads\tcl\ticklecharts-master}
    html:.\render.html

    So it reckonizes windows style paths only

    Maybe this is the reason of weird behaviour too, a kind of clash with internal paths or files o even pipes.

    Probably the solution is to install tcl from cygwin itself, but I really don't understand why it behaves so weird.

    Of course If I execute tclsh from cygwin through cmd.exe everything goes ok:

    $ cmd.exe /c tclsh.exe
    % set h hello
    hello
    % set h
    hello


    Any idea or explanation?

    Are you aware, that tcl may also be build using cygwin?
    Perhaps, there is also a tclsh package within the cygwin distribution (I
    don't know).
    Jan Nijtmans made a lot of effort to get tcl run on cygwin. I remember a conference contribution at ETCL (in Strasbourg, I think).

    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From pd@21:1/5 to All on Mon Mar 27 04:29:18 2023
    El lunes, 27 de marzo de 2023 a las 8:18:36 UTC+2, Harald Oehlmann escribió:

    Are you aware, that tcl may also be build using cygwin?

    I'm pretty sure it can be build using cygwin because cygwin has packages to install tcl

    Perhaps, there is also a tclsh package within the cygwin distribution (I don't know).

    yes there are a few packages:

    $ apt-cyg find tcl
    Trying to download file setup.ini
    Updated setup.ini

    Searching for installed packages matching tcl:

    Searching for installable packages matching tcl:
    mingw64-i686-tcl
    mingw64-x86_64-tcl
    octave-octclip
    pidgin-tcl
    ruby-tcltk
    tcl
    tcl-db
    tcl-db4.8
    tcl-devel
    tcl-itcl
    tcl-itcl-devel
    tcl-itk
    tcl-itk-devel
    tcl-iwidgets
    tcl-ming
    tcl-solv
    tcl-sqlite3
    tcl-tcldot
    tcl-tix
    tcl-tk
    tcl-tk-devel
    tcl-togl
    tcl-togl-devel
    tcl-xapian
    tcl-xapian-doc
    tcl3270
    tcltk
    timidity++-tcltk
    weechat-tcl

    So, as I said previously, this problem should be solved just installed a cygwin package for tcl but I didn't install because I don't want to have two tcl systems installed (magicspalt and cygwin) maybe clashing each other and for sure duplicating space
    without needed. The problem was not so bad I coudn't live with it, it was just a weird problem and I really want to know the reason operating here, just for fun and knowing.

    regards

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From pd@21:1/5 to All on Mon Mar 27 04:21:50 2023
    Hello Brian,

    I think you hit the point,

    El lunes, 27 de marzo de 2023 a las 0:35:57 UTC+2, briang escribió:

    The specific problem here is the "isatty()" posix function. This function does not work correctly in a Windows Console. This function is only used when Tclsh is built for "unix". The Windows build does not use this function. Instead, tclsh is built as
    a Console Application which guarantees a Windows console is present, and tclsh operates accordingly.

    Since the "unix" build uses isatty(), and this function always returns "false" on Windows, tclsh does not enable interactive mode, which disables the prompt. If you type in: set tcl_interactive 1, then the prompt will appear.

    bingo!

    $ tclsh
    set h hello
    []
    set tcl_interactive 1
    1
    % set h hello
    hello
    %

    So I think the conservative solution is to include the line "set tcl_interactive 1" at the beginning of all my scripts so I can use both in mobaxterm shell and windows cmd shell, reasoning it wouldn't affect to windows version (I've tested it)

    Thanks very much to bring peace to my brain ;-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Arjen Markus@21:1/5 to All on Mon Mar 27 06:23:44 2023
    On Monday, March 27, 2023 at 1:29:20 PM UTC+2, pd wrote:
    El lunes, 27 de marzo de 2023 a las 8:18:36 UTC+2, Harald Oehlmann escribió:

    Are you aware, that tcl may also be build using cygwin?
    I'm pretty sure it can be build using cygwin because cygwin has packages to install tcl
    Perhaps, there is also a tclsh package within the cygwin distribution (I don't know).
    yes there are a few packages:

    $ apt-cyg find tcl
    Trying to download file setup.ini
    Updated setup.ini

    Searching for installed packages matching tcl:

    Searching for installable packages matching tcl:
    mingw64-i686-tcl
    mingw64-x86_64-tcl
    octave-octclip
    pidgin-tcl
    ruby-tcltk
    tcl
    tcl-db
    tcl-db4.8
    tcl-devel
    tcl-itcl
    tcl-itcl-devel
    tcl-itk
    tcl-itk-devel
    tcl-iwidgets
    tcl-ming
    tcl-solv
    tcl-sqlite3
    tcl-tcldot
    tcl-tix
    tcl-tk
    tcl-tk-devel
    tcl-togl
    tcl-togl-devel
    tcl-xapian
    tcl-xapian-doc
    tcl3270
    tcltk
    timidity++-tcltk
    weechat-tcl

    So, as I said previously, this problem should be solved just installed a cygwin package for tcl but I didn't install because I don't want to have two tcl systems installed (magicspalt and cygwin) maybe clashing each other and for sure duplicating space
    without needed. The problem was not so bad I coudn't live with it, it was just a weird problem and I really want to know the reason operating here, just for fun and knowing.

    regards
    I have seen this problem also with other programs under Cygwin. I think it is buffering the output to screen in an awkward way.

    Regards,

    Arjen

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Arjen Markus@21:1/5 to Rich on Mon Mar 27 06:22:05 2023
    On Sunday, March 26, 2023 at 5:39:53 PM UTC+2, Rich wrote:
    pd wrote:
    I think this weird behaviour may be related to the fact of using a
    windows program in a "unix" shell environment (cygwin mobaxterm), the tclsh program cygwin is using is the one installed by magicsplat:
    It is. Windows is very different internally from Unix (even if MS
    claims and/or got is certified as 'posix' compatible) and you will find
    lots of little tidbits like this where square pegs just don't fit
    properly into round holes. At the Tcl script level the Tcl runtime
    papers over the differences so the script see's little of them. But at
    the interface just outside the runtime to the rest of the environment
    you are at the mercy of whatever is handling that (in your case the
    cygwin runtime).

    Another one that can be very irritating when one uses "puts stderr" debugging sometimes is that pure GUI programs don't have a stdin/stderr/stdout IO channel available.
    Well, actually, you can get the standard channels to work in a "DOS-box" on WIndows. Try:
    tclsh
    % package require Tk
    [A wish toplevel window appears - at least on my screen]
    8.6.8
    % [type in commands or have [puts] display its results]

    Regards,

    Arjen

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)