[Pkg-sysvinit-devel] Bug#339955: sysv-rc: /etc/init.d/*.sh should be sourced in runlevel S

Brendan O'Dea bod at debian.org
Mon Nov 21 11:20:54 UTC 2005


On Mon, Nov 21, 2005 at 09:34:11AM +0100, Thomas Hood wrote:
>Brendan O'Dea wrote:
>> Note: I believe that "return" should work to exit from a script both
>> when sourced and when executed but perhaps someone with a copy of POSIX
>> could confirm.
>
>
>Disconfirmation:
>
>$ cat /tmp/s
>#!/bin/bash
>echo foo
>return
>echo bar
>jdthood at turmeric:~/src/sysvinit/pkg-sysvinit/sysvinit/trunk/debian/initscripts/etc/init.d$ /tmp/s
>foo
>/tmp/s: line 3: return: can only `return' from a function or sourced script
>bar

Bleah, I tested with "sh test-script", forgetting that I have sh as an
alias for $SHELL (ksh).

In which case, what's needed is "return N 2>/dev/null || exit N", which
should cover all cases.

--bod




More information about the Pkg-sysvinit-devel mailing list