snabelen.no er en av mange uavhengige Mastodon-servere du kan bruke for å delta i det desentraliserte sosiale nettet.
Ein norsk heimstad for den desentraliserte mikroblogge-plattformen.

Administrert av:

Serverstatistikk:

384
aktive brukere

#b

11 innlegg11 deltakere0 innlegg i dag

How to read just one byte from a file in `bash` without external programs?

`nixpkgs` attempted to use `read ... -n 1` and failed miserably:

$ f() { fd= b=; exec {fd}< /dev/urandom; read -r -n 1 -u "$fd" b; echo ${#b}; };f;f;f
2
1
2

It looks like `LANG=C` is enough to make char == byte:

$ f() { fd= b=; exec {fd}< /dev/urandom; LANG=C read -r -n 1 -u "$fd" b; echo ${#b}; };f;f;f
1
1
1

Discovered in github.com/NixOS/nixpkgs/pull/

Without the change isMachO fails to work on UTF-8 locales as read -u 4 decoders 4 UTF-8 chars and not 4 bytes. LANG=C forces it to read bytes.
Closes: #431934

Things done


Built on platform:

 x8...
GitHubstdenv/setup.sh: fix isMachO detection after bash-5.3 update by trofi · Pull Request #432097 · NixOS/nixpkgsAv trofi
Fortsettelse av samtale

Senesence
‘Two bodies nestled into stone strata echo the motif of becoming one with the land. The swirling patterns of rocks mirror the emotional and spiritual turbulence within; the human figures suggests vulnerability, protection and rebirth – an ancient theme found in both Persian poetry and archetypal narratives’

Photo by Azita Gandjei

@photography
#photography
#B&W