OpenRC / openrc

The OpenRC init system
BSD 2-Clause "Simplified" License
1.47k stars 247 forks source link

einfo applet printf format handling #260

Open TerraTech opened 5 years ago

TerraTech commented 5 years ago

Gentoo: default/linux/amd64/17.0/hardened (stable) OpenRC: sys-apps/openrc-0.38.3

Looking at the einfo.3 manpage, I see that the library supports printf format handling, however the src/rc/do_e.c applet handler doesn't seem to allow for this: Neither by direct binary execution nor by sourcing in /lib/rc/sh/functions.sh

int
einfo(const char * restrict format, ...);
$ /lib/rc/bin/einfo "%s" "test"
 * %s test

Was it intentional when the applet executor was designed that it not allow printf format handling?

As it stands, the only way to work around this is to perform a subshell fork to printf, or a back-to-back call:

 $ /lib/rc/bin/einfo $(printf "%s" "test")
 * test
-OR-
$ /lib/rc/bin/einfon ""; printf "%s" "test"   (*to avoid the subshell fork)
 * test

TIA!

vapier commented 5 years ago

afaict, the e* programs have behaved this way for over a decade. based on the lack of complaints, prob best to just leave it that way.

TerraTech commented 5 years ago

Yes, but adding printf formatting ability doesn't take anything away. It is an enhancement that aligns to the documented behavior with 100% backwards compatibility.

vapier commented 5 years ago

it isn't 100% backwards compatible, although i suspect the usage that'd be broken no one would notice.

on the other hand, not supporting a feature no one is really asking for takes less work than supporting it.

TerraTech commented 5 years ago

Fair enough, however in the future would you be open to a PR to implement?

vapier commented 5 years ago

maybe you can convince William. I don't expect the code to be that complicated to pull off, it's just that at this point, tools have migrated away from these low level layers to the point where the only realistic user is openrc itself. and it doesn't seem like this feature would be utilized there.