The Random Thread

My belief is that the people who decide the future of FreeBSD don't take the opinions in this forum into account at all. I'm just stating a belief. Regardless of this, people come here (to the forum) and opine because why not. It's understandable. People like to opine and think their opinions matter. It's also a pastime like any other and healthier than most.

One bumps into surprising assertions, in any case, like "I hate where FreeBSD is going but I'll keep using it no matter what." I will not. If FreeBSD turned into Windows and some other OS took the place left by FreeBSD, I'd switch to that other OS. FreeBSD is a tool, not a banner.
 
This is a sh script that takes the images provided as params and uses graphics/imagemagick to paint a little pink 10x10-pixel square at the center of their left border.

It overwrites the original images with the resulting ones.

I use it to visually mark images that I have discarded but that I keep for my records.

ChatGPT wrote it.

Bash:
#!/bin/sh
# paint-pink-left-center.sh
# Overwrites each input image by painting a 10×10 square centered vertically
# on the left edge (x=0) in hot pink.
#
# Accepts any number of FILE or GLOB arguments (quoted or unquoted).
# Dependency: ImageMagick (mogrify, or magick, or convert) + identify (or magick identify).

set -u

if [ $# -lt 1 ]; then
  echo "usage: ${0##*/} FILE|GLOB [FILE|GLOB ...]" >&2
  exit 64
fi

log() { printf '%s\n' "$*" >&2; }

SQUARE=10

# Select an ImageMagick frontend for writing.
MODE=
if command -v mogrify >/dev/null 2>&1; then
  MODE=mogrify
  log "info: using ImageMagick frontend: mogrify"
elif command -v magick >/dev/null 2>&1; then
  MODE=magick
  log "info: using ImageMagick frontend: magick (mogrify subcommand)"
elif command -v convert >/dev/null 2>&1; then
  MODE=convert
  log "info: using ImageMagick frontend: convert (temp-file in-place emulation)"
else
  log "error: ImageMagick not found (expected: mogrify, magick, or convert)."
  exit 69
fi

# Select an ImageMagick frontend for reading dimensions.
IDENT=
if command -v identify >/dev/null 2>&1; then
  IDENT="identify"
elif command -v magick >/dev/null 2>&1; then
  IDENT="magick identify"
else
  log "error: ImageMagick identify not found (expected: identify or magick identify)."
  exit 69
fi
log "info: using dimension probe: $IDENT"

get_dims() {
  # Prints: "<width> <height>"
  # Returns non-zero on failure.
  f=$1
  $IDENT -format '%w %h' -- "$f" 2>/dev/null
}

compute_rect() {
  # Prints: "<x0> <y0> <x1> <y1>" (inclusive pixel coordinates)
  # Centers a SQUARE×SQUARE region vertically at the left edge.
  w=$1
  h=$2

  # Left edge anchoring.
  x0=0
  x1=$((SQUARE - 1))
  maxx=$((w - 1))
  if [ "$maxx" -lt 0 ]; then
    maxx=0
  fi
  if [ "$x1" -gt "$maxx" ]; then
    x1=$maxx
  fi

  # Vertical centering.
  y0=$(((h - SQUARE) / 2))
  if [ "$y0" -lt 0 ]; then
    y0=0
  fi
  y1=$((y0 + SQUARE - 1))
  maxy=$((h - 1))
  if [ "$maxy" -lt 0 ]; then
    maxy=0
  fi
  if [ "$y1" -gt "$maxy" ]; then
    y1=$maxy
  fi
  if [ "$y0" -gt "$y1" ]; then
    y0=0
  fi

  printf '%s %s %s %s\n' "$x0" "$y0" "$x1" "$y1"
}

draw_corner() {
  # $1: path
  f=$1

  dims=$(get_dims "$f") || return 1
  w=${dims%% *}
  h=${dims##* }

  rect=$(compute_rect "$w" "$h")
  x0=${rect%% *}; rest=${rect#* }
  y0=${rest%% *}; rest=${rest#* }
  x1=${rest%% *}; y1=${rest##* }

  log "info: image dimensions: ${w}×${h}"
  log "info: painting rectangle (inclusive pixels): x=${x0}..${x1}, y=${y0}..${y1}"
  draw="rectangle ${x0},${y0} ${x1},${y1}"

  case "$MODE" in
    mogrify)
      mogrify -fill hotpink -stroke none -draw "$draw" -- "$f"
      ;;
    magick)
      magick mogrify -fill hotpink -stroke none -draw "$draw" -- "$f"
      ;;
    convert)
      # Emulate in-place edit using a temporary file, then atomic replace.
      case "$f" in
        *.*)
          ext=${f##*.}
          base=${f%.*}
          tmp=$(mktemp "${base}.pinkpatch.XXXXXX.${ext}") || return 1
          ;;
        *)
          tmp=$(mktemp "${f}.pinkpatch.XXXXXX") || return 1
          ;;
      esac

      if convert -- "$f" -fill hotpink -stroke none -draw "$draw" "$tmp"; then
        mv -f -- "$tmp" "$f"
      else
        rm -f -- "$tmp"
        return 1
      fi
      ;;
  esac
}

# Preserve spaces in quoted arguments during the "$arg" → glob expansion stage.
oldIFS=$IFS
IFS='
    '
trap 'IFS=$oldIFS' EXIT HUP INT TERM

rc=0
matched_any=0

for arg in "$@"; do
  log "info: expanding argument: $arg"

  expanded=0
  for f in $arg; do
    expanded=1
    matched_any=1

    if [ ! -f "$f" ]; then
      log "warn: skipping (not a regular file): $f"
      rc=1
      continue
    fi

    log "info: processing file: $f"
    if draw_corner "$f"; then
      log "info: done: $f"
    else
      log "error: failed: $f"
      rc=1
    fi
  done

  if [ "$expanded" -eq 0 ]; then
    log "warn: no items produced by expansion for: $arg"
    rc=1
  fi
done

if [ "$matched_any" -eq 0 ]; then
  log "error: no files matched any argument."
  exit 66
fi

exit "$rc"
 
How many languages do you know? I know English, castellano, Hochdeutsch, and more. I even started learning Dutch for 5 seconds because for some reason there's this disproportionately high concentration of FreeBSD users in Holland (does anyone know why?) and because Dutch subtitles looked so funny on in-flight movies when I flew KLM airlines. But if I already know some German, should Dutch be super easy?

Wait, oops, wrong forum for languages other than programming languages?
 
... a beer culture that leaves European cities in the dust. Or do you know any city in Europe that has 50 separate breweries in town?
Qantitiy != quality. Typical American thinking.

And do the 50 breweries all obey the Reinheitsgebot? I don't think so. Having beer that tastes like bubble gum is embarrassing at best.
But if I already know some German, should Dutch be super easy?
Not at all. It may look like this on the first glance but it's completely different.
 
Having beer that tastes like
This is what they do with beer in the Netherlands by the way:

id5975533-GettyImages-2257763325-LSedit.webp
 
I introduced the original post of this recent thread:


Into ChatGPT 5.2 Extended Thinking model and here's its response. I don't paste it on the thread itself because I cannot know how far of being correct it is. To the noob (me) it seems promising, but I now from experience that it can be very wrong.


ChatGPT-generated response

Warning: It has not been confirmed by an expert


Summary of what happened

Both commands likely used the same freebsd-update(8) working directory (default: /var/db/freebsd-update/). Running two instances in parallel causes a race in that shared workspace: one process removes or replaces temporary state while the other still expects it to exist. That produces exactly the observed failures involving transient files such as tINDEX.new, filelist, patchlist, and downloaded files/*.gz.

cut: tINDEX.new: No such file or directory
rm: patchlist: No such file or directory
/usr/sbin/freebsd-update: cannot open filelist: No such file or directory
/usr/sbin/freebsd-update: cannot open files/<hash>.gz: No such file or directory

What requires concern

  • Base system damage is unlikely from the pasted output
    • The host run ended with: “No updates are available to install.” That indicates no changes were committed on the host in that run.
    • The jail upgrade output shown appears to fail while staging metadata/files; the log does not show a completed install/commit phase for the jail.
  • The real problem is a corrupted update workspace
    • The shared workdir is now unreliable. Future freebsd-update(8) runs (host or jail) can keep failing until that workspace is reset.
  • No reboot urgency implied by these logs
    • A reboot is relevant only if a kernel was actually installed. The pasted host output explicitly indicates nothing needed installing.
    • Sanity check on the host: compare freebsd-version(1)() kernel version to uname(1)() runtime version.

Recovery procedure (safe + deterministic)

1) Ensure no instance is still running

Code:
pgrep -af freebsd-update || true

2) Reset the default workdir (rename first to preserve evidence)
Code:
ts=$(date +%Y%m%d_%H%M%S)
mv /var/db/freebsd-update "/var/db/freebsd-update.bad.${ts}"
mkdir -p -m 700 /var/db/freebsd-update
chown root:wheel /var/db/freebsd-update

3) Re-run the host update cleanly
Code:
freebsd-update fetch install

4) Re-run the jail upgrade cleanly using an isolated workdir (-d)
Using -d (see freebsd-update(8)()) prevents host/jail collisions in the future.

Code:
mkdir -p -m 700 /var/db/freebsd-update.myjail
chown root:wheel /var/db/freebsd-update.myjail

freebsd-update -d /var/db/freebsd-update.myjail -j myjail -r 13.5-RELEASE upgrade
freebsd-update -d /var/db/freebsd-update.myjail -j myjail install

Interpretation of specific messages

  • “src component not installed, skipped” is informational: the src component is not present, so it is not updated.
  • The “components installed / not installed” prompt during the release upgrade is normal behavior for freebsd-update(8).
  • The “custom kernel” warning shown during the jail upgrade is not inherently fatal. In a jail context, the running kernel is the host kernel; the warning is primarily about the set of files that will be laid down for the target release.

Fallback if an install had been partially applied (not suggested by the pasted logs)

If an install phase had started and been interrupted, freebsd-update rollback exists to revert the last applied set (see freebsd-update(8)()).
 
The intend of this thread is that one can paste random things just because one feels like sharing them.

Such things don't even have to be so interesting, so my previous response is incorrect in this sense.
 
How many languages do you know?

Depends on who you ask, 2 or 5. Now that wouldn't be my teachers, but linguists and politicians who 'decide' whether 4 south Slavic nations speak the same language or not.

For programming languages I'd say two on this level, too. C I would consider knowing as well as my native language, where I know most of the stuff both in practice and in theory, niche, etc. C++ I'd consider as English, I can also 'think in it' but there are many areas of C++ that are unknown to me. I write and read English every day and can still pick up a new word once in a while. Portend is the one I got yesterday. Same with "modern C++".
 
Depends on who you ask, 2 or 5. Now that wouldn't be my teachers, but linguists and politicians who 'decide' whether 4 south Slavic nations speak the same language or not.

For programming languages I'd say two on this level, too. C I would consider knowing as well as my native language, where I know most of the stuff both in practice and in theory, niche, etc. C++ I'd consider as English, I can also 'think in it' but there are many areas of C++ that are unknown to me. I write and read English every day and can still pick up a new word once in a while. Portend is the one I got yesterday. Same with "modern C++".

If you speak C language then you understand this below:

To: user_id_01 (aka "The Better Half")
From: user_id_00 (aka "The One Who Forgets to Close Braces")
Subject: re: relationship_patch_v2.1.0.c

C:
#include <standard_romance.h>
#include <patience.h>
#include <caffeine.h>

/**
 * Letter for handling daily operations and
 * resolving the "Who Left the Milk Out" bug.
 */

int main() {
    // Initializing emotional state
    struct Human writer = { .mood = "optimistic", .hunger_level = 85 };
    struct Human recipient = { .status = "likely_annoyed", .reason = "trash_not_taken_out" };

    /* * Logic for the upcoming evening
     */
    if (recipient.status == "likely_annoyed") {
        printf("Executing apology.exe...\n");
        do_dishes(ALL_OF_THEM);
        buy_flowers(TYPE_LILIES);
    }

    // Attempting to schedule 'Date Night'
    while (writer.bank_account > 50.00) {
        try {
            initiate_dinner_protocol("That Italian place you like");
        } catch (IndecisionError) {
            // Default to tacos if we can't decide for 45 minutes
            order_takeout(TACO_BELL);
        }
        break; // Prevent infinite loop of hunger
    }

    // Memory Management: Clearing old arguments
    if (days_since_argument > 7) {
        free(grudges);
        grudges = NULL;
        printf("Buffer cleared. Let's start fresh.\n");
    } else {
        // Still processing previous data...
        wait(REASONABLE_AMOUNT_OF_TIME);
    }

    /*
     * Warning: Low battery detected.
     * Suggesting immediate sleep() function.
     */
    if (current_time > 2300) {
        return 0; // Success: Day concluded without a SegFault
    }

    return 1; // Error: Something went wrong, probably forgot the anniversary
}

Developer Notes:
  • Memory Leak Fixed: I’ve finally cleared the cache on that argument we had three years ago about the "right way" to load the dishwasher.
  • Pointer Error: I pointed at the wrong person when I asked who left the wet towel on the bed. It was definitely my null_pointer fault.
 
Remember the forum rules, everybody. I have no idea what they say about discussing the depths and tribulations of the human experience, but keep it civil and classy. And I think no politics or religion are allowed or so said one of Alain De Vos's profile posts.
 
Speaking about Alain De Vos, I begin to suspect that many Forum threads would remain unanswered if it weren't for him.

And to think that the other day a user reproached him for having time additionally to post fun things. This kind of behavior is what fernandel must have been thing about, I believe. SOME humans SOMEtimes are certainly the worst, aren't they POSIX.1?
 
I'll take time to explain myself. I worked years as second line support engineer. Now i'm retired and i want to waste time in doing fun things. As i don't have knowledge of shell scripts or C , so i'm unable to adopt a port. Learning C & reading porters guide is in the pipeline of things, but not for tomorrow. And i don't have time wasting answers on persons who drink in the morning two bottles of vinegar to feel good :)
 
Back
Top