#mksh

R.L. Dane :Debian: :OpenBSD: :FreeBSD: 🍵 :MiraLovesYou:rl_dane@polymaths.social
2026-02-02

P.S., the body of the parent #toot was created by a simple #shell #function:

function apod {
    #Today's NASA Astronomy Picture of the Day info-fetcher
    curl -sL 'https://apod.nasa.gov/apod/archivepix.html' \
        |grep -m1 "[0-9][0-9]:" \
        |sed 's/^/Date: /;
            s|: *<a href="|\nURL: https://apod.nasa.gov/apod/|;
            s/">/\nTitle: /; s/<.*$//'
    echo
    echo "#NASA #Astronomy #PictureOfTheDay"
}

#bash #ksh #mksh #shellScripting #unix #UnixShell #WebScraping #Scraping #HTML

2025-11-10
oh MIPS RISC/os on MAME (MIPS r2000 emulation)
https://virtuallyfun.com/2025/11/10/mips-risc-os-on-mame/

and HP-UX 11i v1 32bit on QEMU PA-RISC
https://virtuallyfun.com/2025/10/26/installing-hp-ux-11i-v1-11-11-32bit-pa1-1-on-qemu-10-1/

maybe I need to try compiling #mksh on them as well. #retrocomputing
2025-10-22
oh. Caldera OpenLinux's bash 1.14.7(1) segfaults when running #mksh Build.sh's genopt. Fortunately it has /bin/ksh(which is PD KSH v5.2.7) which runs it fine.
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 🍵 :MiraLovesYou:rl_dane@polymaths.social
2025-07-06

#Poll: Curious about people's attitudes towards shell scripting.

Two part question:

  1. Are you a DEVeloper (or working in a development-heavy role), OTHER-IT worker (such as a sysadmin, architect, anything in a non-development-heavy role), or NON-IT (accountant, doctor, whatever)
  2. Do you HATE shell scripting, are you INDIFferent towards (or ignorant of) shell scripting, or do you LOVE it?

#Unix #UnixShell #ShellScript #ShellScripting #POSIX #PosixShell #sh #bash #zsh #csh #tcsh #ksh #pdksh #oksh #mksh

2025-05-10

@lanodan @simontatham I actually type cd $PWD + Tab + Enter, as #mksh tab-completes shell parameters in backslash-escaped form (so no splitting), which is easy to type (right tiny finger lies on shift while I press $WD with left hand and P with right pointing finger)

R.L. Dane :Debian: :OpenBSD: :FreeBSD: 🍵 :MiraLovesYou:rl_dane@polymaths.social
2025-04-16

I've probably tooted about this before, but I don't know why this isn't standard.

It's just so obvious, at least to me. ;)

~ $ type mcd
mcd is a function
mcd () 
{ 
    [[ -n $1 ]] && mkdir "$1" && cd "$1"
}

#shell #UnixShell #ShellScripting #sh #bash #ksh #mksh

2025-04-08

@fbfortune depends on the shell, in #mksh use Esc+Ctrl-L instead.

The command clear will also do, or even print \\033c (which does a full reset; on a hardware DEC VT420 it will simulate a power cycle with its long self-test, so be careful).

However, all of these don’t reset the tty state, so you may need to stty sane additionally.

R.L. Dane :Debian: :OpenBSD: :FreeBSD: 🍵 :MiraLovesYou:rl_dane@polymaths.social
2025-03-18

Process Substitution is hella neat.

$ diff important-data.txt <(clipo |sort -u)

(Of course #mksh has it as well ;)

2025-01-14

@regehr @miodvallat incidentally, #POSIX requires that crash for sh so mksh does it in the lksh binary (uses long for arithmetic as POSIX demands) as well.

The standard #mksh language provides 32-bit arithmetic with guaranteed 2s complement, wraparound, shr and sar both defined, negative modulus defined, etc. (and to get there, much cursing at C’s signed integers led me there eventually).

2025-01-12

@justine @rl_dane @rubenerd @sherwoodinc tou get that with PgUp in #mksh in the default (-o emacs, even though I’m no Emacs user) mode, fwiw (but you can rebind it to CurUp if you want).

2024-12-12

@rl_dane nope, I’ve only ever used tar with files, floppy discs (the MirBSD boot floppy is a tape archive), and (inside the VM) an emulated HDD / (outside the VM) the backing store of that HDD for file transfer because I didn’t manage to set up network in some guests (Hurd, Plan 9) but needed to port #mksh to them.

(I even have a SCSI tape drive somewhere but no tape, I think.)

So… what option do I vote for? 😹

2024-10-21

rm'ed my .kshrc, no what?

#ksh #mksh

2024-08-27

@darkuncle @b0rk no -o pipefail in #!/bin/sh, you need #mksh or GNU #bash or so

2024-06-25

@tripplehelix

> @rl_dane What's this doing? [[ ${1:-} ]]

I use set -u in my bash scripts, which causes the script to fail with a warning if you ever reference an undefined variable (it's a good discipline for for bash/ksh, like use strict; use warnings; is for #Perl). Unfortunately, that means that referencing [[ $1 ]] (test if $1 contains any text) will fail if no parameter is passed.

So, as a way around that, I call the "Use default values" shell substitution:

[[ ${1:-} ]]

Which basically says, "Use $1 if it is defined, otherwise substitute the following text: ''"

Hit up the bash, sh or ksh manpage, and just search (/) for ":-". :)

I used to avoid the complex substitution syntax like the plague, because it's so hard to read.
But... it's efficient, as it doesn't have a fork() penalty, and once you learn it, it's not tooo confusing.

#bash #posix #sh #ksh #mksh #ShellScripting

2024-06-25

I love elegant little things in shell:

function inst() {   #is INSTalled?
    type "$@" &>/dev/null
}
function runif() {
    [[ ${1:-} ]] || return 1
    inst "$1" && "$1"
}

...


elif $screen; then
    clear
    runif pfetch || runif ufetch
    ...

#bash #ksh #mksh #UNIX #ShellScripting

2024-06-24

I've had several iterations of this function through the years, which I use to append something to the $PATH variable.

This is about as efficient as I can get it, I think, with the following constraints:

  1. Don't call any external programs
  2. Preserve the order of the $PATH
  3. Never repeat any item in the $PATH
pushpath is a function
pushpath () 
{ 
    [[ -n $1 ]] || return 1;
    PATH=":$PATH:";
    [[ $PATH == *:$1:* ]] || PATH+=":$1";
    PATH="${PATH##:}";
    PATH="${PATH%%:}";
    PATH="${PATH//::/:}"
}

Works in both #bash and #mksh

#ShellScripting #UNIX

Jonathan Perkinjperkin@federate.me.uk
2024-05-01

While we could add a bunch of CHECK_PORTABILITY_SKIP entries to skip these files, I prefer to fix things properly, and so have committed a general fix for this which should speed up most packages.

github.com/TritonDataCenter/pk

Nice reduction in runtime from 86 seconds down to just 1!

If anyone has access to really old systems and are able to tell me if they do not have "read -n" then that'd be hugely appreciated, though it's likely we'd bootstrap #mksh on them anyway.

#pkgsrc #dtrace

Jonathan Perkinjperkin@federate.me.uk
2024-05-01

Interesting performance and behaviour difference between shells and the "read" builtin.

After upgrading to macOS Sonoma I noticed the #pkgsrc check-portability script occasionally taking over an hour and falling foul of my "ulimit -t 3600".

$ wc text-public.js.map
0 960590 13488786 text-public.js.map

Time to "read f < text-public.js.map" and wc $f:

#bash: 0.5 seconds
1 960590 13060347

#mksh: 6.2 seconds
15904 973513 13030108

#dash: 6.4 seconds
15903 973410 13033181

2024-04-23

@bagder we found #mksh’s licence translated to french out of all things in a rental car once

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst