This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Postinstall script errors


Am 12.08.2010 16:54, schrieb Corinna Vinschen:
> On Aug 12 16:52, Matthias Andree wrote:
>> Am 12.08.2010 16:40, schrieb Corinna Vinschen:
>> > On Aug 12 16:10, Matthias Andree wrote:
>> >> Am 12.08.2010 15:37, schrieb Jeremy Ramer:
>> >> > I verified that $created_passwd and $created_group were both no so
>> >> > both conditionals will fail. But because the last conditional is the
>> >> > last thing run, the script returns 1.  Adding an exit 0 to the script
>> >> > fixes it, but I'm not sure if that accomplishes what you want from the
>> >> > script.
>> >> 
>> >> PLEASE DON'T.
>> >> 
>> >> Adding an "exit 0" will mask the error and just reinstate the former state of
>> >> silently failing postinstall scripts more rigidly. This is not desirable. The
>> >> proper way to fix this is:
>> >> 
>> >> set -e  # this is providing that the whole script is written properly.
>> >>         # it causes immediate exit after one command (outside if, and
>> >>         # outside || or && lists) fails - usually desirable, but takes more
>> >>         # work because you can't write the scripts as sloppily as the
>> >>         # snippet you've just shown from passwd-grp.sh.
>> >> #
>> >> # ...other work...
>> >> #
>> >> if [ "$created_passwd" = "yes" ] ; then
>> >> 	/bin/chgrp --silent root /etc/passwd
>> >> fi
>> >> 
>> >> if [ "$created_group" = "yes"  ] ; then
>> >> 	/bin/chgrp --silent root /etc/group
>> >> fi
>> > 
>> > I misinterpreted the `chgrp --silent'.  I thought it would result
>> > in an exit code of 0 from chgrp, but it just suppresses the error
>> > messages.  Sorry about that.
>> 
>> And you're missing the other point that I've just explained on cygwin-apps@, see
>> http://www.cygwin.com/ml/cygwin-apps/2010-08/msg00116.html
> 
> No, I didn't.

Sorry to be so unrelenting, but you are still missing the point. Please re-read
Jeremy's analysis at <http://cygwin.com/ml/cygwin/2010-08/msg00285.html>.

NOTE: *chgrp was not ever run* in the failing scenario, so whatever you pass as
chgrp arguments, --silent or not, is irrelevant.  What actually happened was:

created_group=no
...
[ "$created_group" = "yes"  ] &&  # remainder short-circuited, failure stands

And since this  [  ] && line was the last in the script, the failure from the
"[" (= test) command propagated through to the caller and finally through
setup.exe which duly reported it.

-- 
Matthias Andree

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]