A stray "j" ruined my evening

birdculture1 pts0 comments

how a stray "j" ruined my evening — napkins← back 2026-06-08<br>Some time ago I decided to wrangle a silly link shortener that I called shirts linkener, shirts for short.<br>There's nothing special about it in particular, rather it's in my run-once-forget-forever shell script that copies the generated links to a clipboard using wl-clipboard.<br>#!/bin/sh

shirt=$(curl -s -X POST "$(pass show shirts/url)" \<br>-H "Authorization: Bearer $(pass show shirts)" \<br>-H "Content-Type: application/json" \<br>-d "{\"url\": \"${1?missing url}\"}")

echo "$shirt" | jq<br>echo "$shirt" | jq -r '.short_url' | wl-copyNothing out of the ordinary here. It shortens the link and copies it to a clipboard. By then I have been hapilly using it for couple of months without an issue.<br>The fun began when I decided to try out gurk, a Signal TUI written in Rust. Those who know me, know my obsession with terminal interfaces so this was an obvious match.<br>One evening I was sharing a link to an image hosted on S3 when I noticed people were saying it shows 404 to them.<br>After pasting the link into Firefox, it worked. What is going on? I send them the link and it works now...<br>Time passes and I get the same responses from multiple friends - 404. After some time looking at the messages I notice a pattern - each url ends with "j".<br>Turns out I was copying the link with a \n at the end, which in most cases went unnoticed, but in ANSI newline delimiter is translated as "j", hence the stray jay at the end of each link.<br>After having a solid five minutes of immense shame I found that jq has --join-output argument, which prevents exactly my case:<br>--join-output / -j:

Like -r but jq won't print a newline after each output.Moral of this story is that terminals are fun and shooting myself in the foot repeatedly acts as a great learning opportunity.<br>Some of the sources around control codes and escape sequences.<br>https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797<br>https://cirw.in/blog/bracketed-paste<br>https://jdhao.github.io/2021/02/01/bracketed_paste_mode<br>m.

link shirts after stray evening time

Related Articles