[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#490605: Bug#532324: udev init script bash+dashism: assumes printf is a builtin

Hash: RIPEMD160

Debian Policy 10.4 states that shell scripts using a /bin/sh shebang
line must conform to POSIX Shell, with a few (listed) exceptions.

specifies, under “Command Search and Execution” 1.c, a list of required
shell builtins. I cannot find printf(1) there, or in any other place of
current SUSv3 (online edition), for that matter, except as stand-alone

udev uses /bin:/sbin as $PATH whereas printf(1) lies in /usr/bin.

udev uses printf nevertheless, assuming it right because GNU bash sup-
ports it and dash, unlike posh (I think) and other Debian Policy 10.4
compliant /bin/sh-capable shells, implements it as a speed hack (lower
boot times combined with portable use of printf, since echo isn’t).

I call for the CTTE to decide that no maintainer is above Policy 10.4
and that udev shall be fixed to not use printf as builtin, or require
a different shebang.

My proposals:

① udev in sid will be changed to use "#!/bin/dash" as shebang;
  udev in lenny will be changed to use "#!/bin/bash" as shebang.
  The change in lenny is necessary, as it is affected as well.

② udev in both sid and lenny will be changed to not use printf
  any more.

Both ① and ② need to override the maintainer’s decision.
I would be most pleased if one of the above were to be decided upon.

③ coreutils will be changed to move /usr/bin/printf to /bin/printf
  and have a /usr/bin/printf@ → ../../bin/printf symbolic link.

  I do not like this. It is non-standard, an evil workaround, and
  will(!) lead to the creation of more unportable scripts.

④ dash will be changed to have the printf builtin removed, so that
  maintainers will be forced to change their scripts.

  I do not like this. Debian uses dash to provide a rather minimal
  /bin/sh for quick system startup. While the presence of a printf
  builtin is a speed hack, it serves this purpose well. Other shells,
  including bash, ksh93, mksh and posh, but not pdksh, can be used
  to validate scripts instead.

⑤ Debian changes policy to allow the use of bash+dash as /bin/sh.

  I do not like this, for similar reasons as in ③, as well as for
  the fact that I fought to have mksh an allowed /bin/sh in Debian,
  which has led to improvements upstream. These may be personal,
  but I expect this proposal to be rejected due to the unportabi-
  lity argument.

I think using printf is okay *as long* as it it possible for the
script to pick it up in /usr/bin/ and *not* rely on an unportable
builtin. The whole point of Policy 10.4 is portability, and maybe
even portability beyond Debian. It _is_ well-known, after all,
that shell and utility "echo" are both unportable. (This serves
as comment to #490605.)

The motion to have maintainer scripts, whether in udev or other
places, fixed so that /bin/sh can be a shell other than GNU bash
or dash, is supported (as in, they don't like the current situa-
tion) by the DDs Alexander Wirt, Gerfried Fuchs, and possibly

Thank you very much for your consideration.

//mirabilos – mksh Debian Maintainer – Project Leader, The MirOS Project
- -- 
I believe no one can invent an algorithm. One just happens to hit upon it
when God enlightens him. Or only God invents algorithms, we merely copy them.
If you don't believe in God, just consider God as Nature if you won't deny
existence.		-- Coywolf Qi Hunt
Version: GnuPG v1.4.7 (MirBSD)


Reply to: