WordBash

The WordPress clone written in GNU Bash

header image

Download

Posted on May 21, 2024

WordBash is a Bash Shell Script

Code is here: wordbash-1.0.3.zip and there: Git it WordBash.

Oh, Oo

17 Feb 2026
There is going to be a new release... We are actually at... v1.0.4!

Bug Log

17 Feb 2026
Some of the links to the theme code and the links for Home and Download had been entered wrong by The SysOp. We don't know when that typing error was committed... He has been sufficiently flogged.

Sometime in early 2024
Ugh, the perils of multi-platform cookery...

FILE: libs/S.sh

    06:SEXP=30
    07:SDFM="+%a, %d %b %G %T GMT"
    ...
    22:	d=`date -v +${Sd}d "$SDFM"`
    23:	echo "Expires=$d"

That is wrong—it's left-over OS-X shit that is supposed to set a date some 30-something in the future. (Days I guess.)

This aught to keep it from failing:

    22: d=`date "$SDFM" -d "next day"`

But also it should be based on something like this:

    22: d=$(printf "%($SDFM)T" $EPOCHSECONDS)

But that too exposes an error in my coding, that of the "+" in the date string. The code should have been:

    SDFM="%a, %d %b %G %T GMT"
    d=`date "+$SDFM" -d "next day"`

That sole little plus is a big f*cking deal. This has been fixed.

Way long ago:

FILE: B.sh

158:    ${start:=0}

That should be:

158:    : ${start:=0}

I think there is at least one more of those. This has been fixed.

--

The code is not very robust, which means that there are stuff like this:

    [[ $arg -eq 0 ]]

Nothing wrong with that except when $arg is not an integer. The non-robustness is that for simplicity the posts and pages here are stored as numbered files, so querying the database is simply:

    dl=($Pd/*)
    dl=(${dl[@]#$Pd/})

Where $Pd is the directory, and the result is an array of numbers, which can then be counted, sorted, listed, etcetera. But, if by accident, a non-numerical file was created in the directory... there gonna be an improper arithmetic expression in one of those loops—actually there's gonna be: invalid arithmetic operator.

Of course, I am just being a bit lazy as perhaps all that is needed is a better glob..

But, wait, there's more!

But that is the core premise of WordBash, the question of, "What is the absolute minimum required to read/write a post?" Obviously, that is a file. (And lest anyone protest, a "database" is a file—albeit multiple files—as it cannot be anything else. Using fancy words like "cloud" and "distributed" ain't changing nothing.)

So, if a post is a file, the read can be as simple as:

    $(< $file)

But of course only if the file is stored formated with HTML, like by using a javascript rich text editor.

But the other things required is some meta-data like post title, date, author etcetera. That is usually part of the database schema:

    CREATE TABLE poost (
      ID INTEGER,
      Name CHAR(40),
      Title CHAR(200),
      Date DATE,
      PRIMARY KEY (ID)
    )

Okay, fine. But, WTF? How about that RFC stuff? Since, like, what, 1977? Yeah. That shit.

    name:C.B.Jones
    title:Download
    date:May 21, 2024
    
    <h2>WordBash is a Bash Shell Script</h2>
    ...

Of course, I'm even dumber than that. I do:

    Download
    May 21, 2024

    <h2>WordBash is a Bash Shell Script</h2>
    ...

Cause name is always just mine, and like first come first server order (deny, allow!) first line is title, second is date, and a blank line terminates headers and then starts the body.

And, of course, that can be done in Bash in just a few lines! Fuck! Ain't this shit cool! It's not unlike something like this:

    Dr=$(< $dir/$file)
    I=$IFS; IFS=$'\n'
    Dh=(${Dr%%$'\n'$'\n'*})
    IFS=$I

Or how 'bout something really lame like this:

    while read -r l; do
        if [[ "$l" == "" ]]; then
            break
        fi
        Dh[$i]=$l
        (( ++i ))
    done < "$1/$2"

Yeah, I guess it's just me. We really need a bloody structured query language to do anything like this. Yeah.