🤔 A Bug(?) in BBEdit feeds command input all on one line

I just came across a strange bug in BBEdit. I’m not sure if it’s me, yet, but it seems like when you use the “Run Unix Command” over several lines of text, it feeds the whole thing as one contiguous line to the command you’re running. This can be problematic if the command you’re running chokes on long lines. In my case, I was running column to try and get a poor-man’s “align assignments” feature. column’s man page helpfully tells me that it limits it’s lines to 2048 bytes, which would explain why things error out when I try to run it over this text, especially if BBEdit is smashing it all into one line, newlines and all. ChatGPT helpfully crafted a workaround that seems to do the job in column’s stead:

#!/bin/bash
# Align assignments by = for BBEdit Text Filter
awk -F '=' '
{
    if (NF > 1) {
        key = $1
        val = substr($0, index($0, "=") + 1)
        gsub(/[ \t]+$/, "", key)
        gsub(/^[ \t]+/, "", val)
        keys[NR] = key
        vals[NR] = val
        if (length(key) > max_key_len) {
            max_key_len = length(key)
        }
    } else {
        raw[NR] = $0
    }
    line_num[NR] = 1
}
END {
    for (i = 1; i <= NR; i++) {
        if (line_num[i]) {
            if (keys[i] != "") {
                printf("%-*s = %s\n", max_key_len, keys[i], vals[i])
            } else {
                print raw[i]
            }
        }
    }
}'

As you can see, it’s mostly awk. However, when life gives you lemons, you surgically remove the peel and carefully extract the juice with deep Unix arcana.

I emailed support, lets see what they have to say.