On 11/22/18, Ian Jackson <ijack...@chiark.greenend.org.uk> wrote: > Mert Dirik writes ("Re: Bug#913247: Please provide a C implementation of > /lib/init/init-d-script"): >> On 11/22/18, Ian Jackson <ijack...@chiark.greenend.org.uk> wrote: >> > So I think this would be fixed if /lib/init/init-d-script detected >> > this situation and set $0 to the original script name (which it gets >> > in $1). That is probably desirable anyway. >> >> The problem is there is no way of setting $0 inside a shell script as >> far as I know. So either init-d-script shouldn't be used in shebang or >> 40-systemd should handle a special case for it (this is up to the >> systemd maintainers as 40-systemd is in systemd package) > > Ah, yes. I looked at the dash manpage and didn't see anything > appropriate. But it would be a simple matter to invent a new > variable, surely. >
"__init_d_script_name" variable is set inside init-d-script before sourcing /lib/lsb/init-functions and it can be used for this purpose.