[go: up one dir, main page]

Today I Learned

tags


2021/09/06

about PATH_MAX: the part of the POSIX standard which determines the maximum number of bytes allowed in an absolute path. In Linux, PATH_MAX is 4096 [src], but it’s possible to construct longer paths if you don’t care about some (most) utilities that use the current working directory to fail due to buffer overflow.

Also, I learned that most filesystems restrict file names to 255 bytes.


2021/10/04

that different versions of sort(1) have different sorting presets. For example, on ubuntu 20.04 vs debian buster, sort will swap the order of how it sorts _s. These differences can be resolved by passing --unique --dictionary-order --stable.

Bonus: -h/--human-numeric-sort can sort SI suffixes.


2022/01/31

that the fmt utility exists. It seems to fold or center text according to a target width.


2023/10/31

That POSIX shell has configuration option, set -a or set -o allexport that exports all assigned variables. This simplifies using .env files in .envrc files:

# evaluate a .env file, if it exists
if [ -f .env ]; then
  set -a # assigning a variable exports the variable
  # shellcheck disable=SC1091
  source .env
  set +a
fi

That JS has a String.raw template literal tag function that unescapes escape sequences in a backtick-string:

String.raw`\t\r\n` // => "\\t\\r\\n"