[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: How to check if script invoked from main shell
From:       Laurent Bercot <ska-dietlibc () skarnet ! org>
Date:       2012-07-28 16:30:39
Message-ID: 20120728163039.GA20474 () skarnet ! org
[Download RAW message or body]

>> I need to change behavior of shell script(s) if they get invoked from a
>> main shell, that is a shell (interactive or not) which is a direct
>> child of process #1 (init). How to determine if script has been invoked
>> in this environment? What is the best/easiest solution for this?

 Hi Harald,

 Allow me to answer your question with another question: what are you
trying to accomplish here ?
 Because the separation you are trying to implement doesn't look
natural and clearly defined to me. For instance, what if your doit script
is called from a subshell of a top-level shell ? Sometimes shells fork
without telling you. What behaviour do you want to have in that case ?

 The only natural distinction you can make is between a boot-environment
shell and a login-environment shell. It is pretty easy to distinguish
those, via environment variables, and it often makes sense to do so
(for instance, you do not want to run services in a login environment -
it's a major cause of bugs and sysadmin headaches with System V setups.)

 Isn't that natural distinction enough for your purposes ?

-- 
 Laurent
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic