Improve quine printf

This commit is contained in:
cubernetes 2026-10-23 17:39:46 +02:00
parent f1573d922d
commit 383b243ebd

View file

@ -94,18 +94,14 @@ bashrc_forward () {
[[ "${ENV##*/}" =~ ^[0-9]+$ ]] && builtin eval "builtin exec ${ENV##*/}<&-"
#-# Constructs new ENV after every command, thanks to the quine
builtin exec {ENV}< <(
printf %s "${_s@A}
$_s"
)
builtin exec {ENV}< <(printf "%s\\n%s" "${_s@A}" "$_s")
export ENV="/dev/fd/$ENV"
'\''\'\'''\''\'\''\'\'''\'''\''\'\'''\''
'\''\'\'''\''
printf %s "${_s@A}
$_s"
printf "%s\\n%s" "${_s@A}" "$_s"
#-# Suppress the warning `bash: POSIXLY_CORRECT: readonly variable` using a one-shot DEBUG trap
#-# `PS0` and `PROMPT_COMMAND` will not suffice, `PROMPT_COMMAND` runs AFTER the command, therefore