• Extensions in shells

    From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Saturday, July 25, 2026 01:03:33
    On 24/07/2026 8:34 PM, Janis Papanagnou wrote:

    Historically it was typical to have the specific tasks separated...

    Like, "echo", "ls", ..., don't actually do enough to justify the
    overhead of spawning a new process.

    ...where newer shells typically have made sensible decisions and built
    in functions like 'echo' and 'printf', and added syntactic constructs,
    like '[[...]]' that made the former external '[' command (meanwhile
    often also built-in) unnecessary.

    Concerning 'ls', I don't think that this is primitive enough to become
    a built-in; inspect the many options you typically get with it, even
    if you only restrict to the POSIX subset. (And for shell scripting you
    often don't even need 'ls' since filenames are typically obtained by
    other ways and can be obtained even by wildcards in any context.)

    (What I'm actually missing is a shell built-in 'stat' command; I think
    that would be sensible. But that's just my personal opinion.)


    This is trivial, for some value of trivial, by making a Zsh extension.

    I've previously written one in C -- of course -- but now the code is
    lost. What I did for fun was to create a binding for OpenGL. It was
    enough to show a triangle on a screen. Today, I'd probably do the same
    via SDL3, or even SDL2, and OpenGL rather than GLUT.


    And by now, it seems I snipped the part where you mentioned ksh. Does
    ksh also have a mechanism for dynamic modules?
    --
    Johann | email: invalid -> com | www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | twitter: @myrkraverk

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Friday, July 24, 2026 23:33:43
    On 2026-07-24 19:03, Johann 'Myrkraverk' Oskarsson wrote:
    On 24/07/2026 8:34 PM, Janis Papanagnou wrote:

    Historically it was typical to have the specific tasks separated...

    Like, "echo", "ls", ..., don't actually do enough to justify the
    overhead of spawning a new process.

    ...where newer shells typically have made sensible decisions and built
    in functions like 'echo' and 'printf', and added syntactic constructs,
    like '[[...]]' that made the former external '[' command (meanwhile
    often also built-in) unnecessary.

    Concerning 'ls', I don't think that this is primitive enough to become
    a built-in; inspect the many options you typically get with it, even
    if you only restrict to the POSIX subset. (And for shell scripting you
    often don't even need 'ls' since filenames are typically obtained by
    other ways and can be obtained even by wildcards in any context.)

    (What I'm actually missing is a shell built-in 'stat' command; I think
    that would be sensible. But that's just my personal opinion.)


    This is trivial, for some value of trivial, by making a Zsh extension.

    I've previously written one in C -- of course -- but now the code is
    lost.ÿ What I did for fun was to create a binding for OpenGL.ÿ It was
    enough to show a triangle on a screen.ÿ Today, I'd probably do the same
    via SDL3, or even SDL2, and OpenGL rather than GLUT.


    And by now, it seems I snipped the part where you mentioned ksh.ÿ Does
    ksh also have a mechanism for dynamic modules?

    You can for example write a C-function and load it from Kornshell using
    the 'builtin' command.

    NAME
    builtin - add, delete, or display shell built-ins

    SYNOPSIS
    builtin [ options ] [pathname ...]

    DESCRIPTION
    builtin can be used to add, delete, or display built-in commands in
    the current shell environment. A built-in command executes in the
    current shell process and can have side effects in the current shell.
    On most systems, the invocation time for built-in commands is one or
    two orders of magnitude less than commands that create a separate
    process.

    For each pathname specified, the basename of the pathname determines
    the name of the built-in. For each basename, the shell looks for a C
    level function in the current shell whose name is determined by
    prepending b_ to the built-in name. If pathname contains a /, then
    the built-in is bound to this pathname. A built-in bound to a
    pathname will only be executed if pathname is the first executable
    found during a path search. Otherwise, built-ins are found prior to
    performing the path search.

    If no pathname operands are specified, then builtin displays the
    current list of built-ins, or just the special built-ins if -s is
    specified, on standard output. The full pathname for built-ins that
    are bound to pathnames are displayed.

    builtin cannot be invoked from a restricted shell.



    I've played with Kornshell built-ins in the past. And it may be useful.

    But doing a quick test with my old code strangely fails with ksh93u+m,
    I get: "builtin: adding built-ins not supported"! - WTF?
    Obviously some things have changed in Martijn Dekker's ksh version. A
    quick test of 'builtin' with AT&T ksh93u+ is still working, though.[*]
    But Martijn Dekker's ksh93u+m version's 'builtin' man-page (sadly) says
    -f lib Not supported.
    -l No effect.
    where AT&T's ksh93u+ documents verbosely
    -f lib On systems with dynamic linking, lib names a shared
    library to load and search for built-ins. Libraries
    are searched for in ../lib/ksh and ../lib on $PATH
    and in system dependent library directories. The
    system dependent shared library prefix and/or
    suffix may be omitted. Once a library is loaded,
    its symbols become available for the current and
    subsequent invocations of builtin. Multiple
    libraries can be specified with separate
    invocations of builtin. Libraries are searched in
    the reverse order in which they are specified.
    -l List the library base name, plugin YYYYMMDD version
    stamp, and full path for -flib on one line on the


    The point of the statement in my post (seeking for a builtin 'stat')
    was the wish to have it available natively as built-in. The reason is
    that I prefer the standard environments of tools and avoid personal or proprietary additions.

    Concerning 'stat' I typically have also no performance requirements on
    that command, so it's more like a nice-to-have than a strong demand.

    Janis

    [*] In the past I had suggested to prefer ksh93u+m over ksh93u+, but
    meanwhile I'm not that sure any more; there's quite some ksh features
    that I had used in the past not any more supported by Martijn's branch.
    :-(


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Saturday, July 25, 2026 02:25:05
    On Sat, 25 Jul 2026 01:03:33 +0800, Johann 'Myrkraverk' Oskarsson wrote:

    This is trivial, for some value of trivial, by making a Zsh
    extension.

    Many apps that allow addons/plugins are moving away from allowing
    third-party code to execute within their process context. Instead, the addon/plugin executes in its own process, with communication with the
    parent app handled via an IPC protocol buried within an API library of
    some sort.

    Examples: GIMP, Inkscape.

    A shell could provide something similar -- if it wants third-party
    code messing with its internal context. Otherwise I would avoid it.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Saturday, July 25, 2026 18:07:02
    On 25/07/2026 10:25 AM, Lawrence D?Oliveiro wrote:
    On Sat, 25 Jul 2026 01:03:33 +0800, Johann 'Myrkraverk' Oskarsson wrote:

    This is trivial, for some value of trivial, by making a Zsh
    extension.

    Many apps that allow addons/plugins are moving away from allowing
    third-party code to execute within their process context. Instead, the addon/plugin executes in its own process, with communication with the
    parent app handled via an IPC protocol buried within an API library of
    some sort.

    Examples: GIMP, Inkscape.

    A shell could provide something similar -- if it wants third-party
    code messing with its internal context. Otherwise I would avoid it.

    Zsh has a well established set of extensions. For example, there's
    the /stat/ system call we were previously talking about, though I was originally thinking of /ls/ as an extension to build in C.


    https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#The-zsh_002fstat-Module

    On the graphics front, I've moved away from GIMP and Inkscape, and
    now use CorelDRAW and Photo-Paint. As far as I can tell, they still
    offer direct binary plugins. I'll quote their manual.

    Solutions based on VBA Macros, VSTA plugins and C++ plugins all run in
    the context of the host applications such as CorelDRAW, Corel PHOTO-
    PAINT, Corel DESIGNER.

    If you absolutely need open source tools, CinePaint is still on life
    support, and I doubt they've removed the binary plugin feature.

    http://cinepaint.org/


    Happy drawing!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Saturday, July 25, 2026 22:39:24
    On Sat, 25 Jul 2026 18:07:02 +0800, Johann 'Myrkraverk' Oskarsson wrote:

    On the graphics front, I've moved away from GIMP and Inkscape, and
    now use CorelDRAW and Photo-Paint.

    You enjoy getting locked into rentware, do you?

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Monday, July 27, 2026 00:31:42
    On 26/07/2026 6:39 AM, Lawrence D?Oliveiro wrote:
    On Sat, 25 Jul 2026 18:07:02 +0800, Johann 'Myrkraverk' Oskarsson wrote:

    On the graphics front, I've moved away from GIMP and Inkscape, and
    now use CorelDRAW and Photo-Paint.

    You enjoy getting locked into rentware, do you?

    What did you do? Why did you /rent/ CorelDRAW? Did you not notice
    that before the checkout, you can choose the /CorelDRAW Graphics Suite
    2026/ as a one time purchase for $859? There are cheaper options, and
    I even found new copies of older versions for much less on Ebay. I
    just use 2021, which doesn't have any of the AI features; or none that
    I noticed.

    Well, whatever, done is done, and I wish you happy graphics design with
    your rental copy!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Sunday, July 26, 2026 22:56:52
    On Mon, 27 Jul 2026 00:31:42 +0800, Johann 'Myrkraverk' Oskarsson wrote:

    I just use 2021, which doesn't have any of the AI features; or none
    that I noticed.

    Would you entrust mission-critical business operations to obsolete,
    unsupported software?

    Did you not notice that before the checkout, you can choose the
    /CorelDRAW Graphics Suite 2026/ as a one time purchase for $859?

    That?s quite expensive, if it?s just a hobby ...

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)