an excerpt of a startup script looks like this:
ENABLED=1
test "$ENABLED" != "0" || exit 0
The problem is, no matter if Enabled is set to 0 or 1, the script always exits at that line. I looked up "man test" and as far as I understand it, test will always evaluate the expression and then exit(!!) with the return code? Is this correct. So This script will, at this line, always exit no matter what the value of the variable is? (so its buggy).
thanks!! jens
when i run this, i get
So, it seems to me that either
That test statement basically says "exit with return code 0 (which usually means OK in this wonderful world of Linux/Unix) if $ENABLED is set to something else than 0".
Did this clarify you at all? It's hard to tell you more without seeing the complete start-up script :-)
With some general assumption here, in an attempt to answer the question specifically, that is:
Yes, more or less, but not necessarily exit the entire script. And also, no, it's not buggy; if my assumptions are correct.
As others have mentioned, it's difficult to give a definitive answer without seeing more of the script, but I would imagine there was reason for your unwillingness to share what package it is you've added which I make no attempt to pass judgement on. Rather, it is merely to assume your pardon in assuming that this little snippet from your script is near the beginning, shortly after some parameters are declared such as PATH, NAME, etc. and there is more to the script, probably most of it, following this. (Hence, the seemingly preposterous response as to why the script has this.)
To clarify, more than likely this part of the script is merely there to ensure that when the script launches, an instance of the function/process it calls/uses is not already launched or in use. In other words, if a script calls for
program
then basically, this checks ifprogram
is already running, if yes, exit quietly, then the script can continue with assurance of being able to launchprogram
without running into an errors involving another process or instance already running. Especially if an already launched process was set with different parameters than the script calls for, then you'd blame the script.Again, assumptions were made and the explanation is broad, but hopefully that helps clarify any passerby to this decade-old question.
pfftt, 170 views over 11 years...ah well, it just takes one vote to make it all worth it!