[Toybox] hostname vs ${x at P}

Rob Landley rob at landley.net
Sat Sep 19 23:10:36 UTC 2026


How do I reset what bash thinks the hostname is?

$ sudo unshare -u bash -c 'hostname lorax; hostname; cat 
/proc/sys/kernel/hostname; export HOSTNAME=lorax; abc="\H \h"; echo 
${abc at P}'
lorax
lorax
driftwood driftwood

It seems too have cached it internally in a way that seems a bit awkward 
to write reproducible tests. (This started with me trying to test \H vs 
\h because my laptop's default hostname doesn't have a . in it, but...)

I guess:

$ sudo unshare -u bash -c $'hostname drift.wood; bash -c \'abc="\h \H"; 
echo ${abc at P}\''
drift drift.wood

Should I reproduce this behavior in toysh? (Is there a reason for it? Is 
the gethostname(2) syscall expensive?)

Rob


More information about the Toybox mailing list