rc scripts and stderr

Onno Benschop onno at itmaze.com.au
Fri Dec 5 00:05:58 UTC 2008

On 02/12/08 07:34, Tom Van Looy wrote:
> Hi
> $ sudo service --status-all 2>/dev/null | grep -i usage
> Usage: /etc/init.d/console-setup {start|reload|restart|force-reload|stop}
>   * Usage: hwclock.sh {start|stop|reload|force-reload|show}
>   * Usage: hwclock.sh {start|stop|reload|force-reload|show}
> Usage: /etc/init.d/keyboard-setup {start|reload|restart|force-reload|stop}
> Usage: /etc/init.d/linux-restricted-modules-common {start}
> Usage: /etc/init.d/loopback {start|stop|restart|force-reload}
> Usage: /etc/init.d/networking {start|stop|restart|force-reload}
> Usage: /etc/init.d/openbsd-inetd {start|stop|reload|force-reload|restart}
> Usage: /etc/init.d/readahead {start|stop|restart|force-reload}
> Usage: /etc/init.d/readahead {start|stop|restart|force-reload}
> Usage: /etc/init.d/udev {start|stop|restart|reload|force-reload}
> Usage: /etc/init.d/udev {start|stop|restart|reload|force-reload}
> Some tools print their "usage" to stderr, some tools print to stdout. I 
> don't like to see "Usage" prints on stdout. Because, that kinda screws 
> up the --status-all output. Isn't there some kind of standard (like LSB) 
> that, ideally, should be followed?
> I'm just digging into Ubuntu so I'm pretty new at how things are rolled 
> in Linux land. But this seems not right ... Is someone thinking about 
> solving this? It seems the work is in changing all the rc scripts in 
> packages so that they act in a uniform way (maybe add a "status" option 
> to all of them too). I know bash so I could submit some patches :-)
> And now that I'm asking. What are the prefered CLI tools (that come with 
> the base system) to manage the rc scripts? Or am I supposed to just edit 
> the files.
> Kind regards,
> Tom
The script to manage rc scripts is update-rc.d

There is a bug and patches for dealing with status -

The comment about "usage" being sent to stderr is interesting, a quick
grep though intrepid gives the following data:

    * There are 83 occurrences of "Usage:"
    * Of those, 49 are diverting output to ">&2"
    * The rest (34) are not diverting output on the echo itself, though
      I didn't dig deeper to see if the redirect happened at any other
      point in the script.

This indicates to me that there isn't a standard implementation of
"correct" behaviour.

I was unable to locate an answer from the LSB standards, but as I see
it, the "Usage:"-message would only come up with an incorrect/incomplete
invocation of an init.d script, indicating to me that it should only be
sent to stderr.

Onno Benschop

Connected via Optus B3 at S31°54'06" - E115°50'39" (Yokine, WA)
()/)/)()        ..ASCII for Onno..
|>>?            ..EBCDIC for Onno..
--- -. -. ---   ..Morse for Onno..

ITmaze   -   ABN: 56 178 057 063   -  ph: 04 1219 8888   -   onno at itmaze.com.au

More information about the Ubuntu-devel-discuss mailing list