This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: [PATCH v3] [BZ #14579] rtld: limit self loading check to normal mode only


On Fri, Sep 14, 2012 at 06:21:52PM -0700, Roland McGrath wrote:
> > +	$(SHELL) -e $^ > $@
> 
> If you want -e behavior, it's better to put 'set -e' inside the script so
> it's self-contained rather than implicitly expecting an unusual invocation.

If script relies upon -e behavior, then 'set -e' is preferable.  However,
the current glibc practice is $(SHELL) -e:

$ git grep -F '$(SHELL)' */Makefile
catgets/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
elf/Makefile:	$(SHELL) -e $< $(common-objpfx)
elf/Makefile:	$(SHELL) -e $^ > $@
grp/Makefile:	$(SHELL) -e tst_fgetgrent.sh $(common-objpfx) $(elf-objpfx) \
iconvdata/Makefile:LC_ALL=C $(SHELL) ./gen-8bit.sh $< > $(@:stmp=T)
iconvdata/Makefile:LC_ALL=C $(SHELL) ./gen-8bit-gap.sh $< > $(@:stmp=T)
iconvdata/Makefile:	LC_ALL=C $(SHELL) ./gen-8bit-gap-1.sh $< > $(@:stmp=T)
iconvdata/Makefile:	$(SHELL) -e $< $(common-objdir) > $@
iconvdata/Makefile:	$(SHELL) $< $(common-objpfx) $(common-objpfx)iconvdata/ > $@
intl/Makefile:	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ \
intl/Makefile:	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
intl/Makefile:	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
intl/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/
intl/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/
io/Makefile:	$(SHELL) -e ftwtest-sh $(shell cd $(common-objpfx). && pwd)/ \
libio/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)'	\
localedata/Makefile:	@$(SHELL) -e gen-locale.sh $(common-objpfx) '$(built-program-cmd)' $@
localedata/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(test-input) \
localedata/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' tst-fmon.data \
localedata/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' tst-numeric.data \
localedata/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)' > $@
localedata/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)' > $@
localedata/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)'
localedata/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)'
localedata/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
localedata/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
localedata/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
malloc/Makefile:	$(SHELL) -e $< $(common-objpfx)
manual/Makefile:	AWK=$(AWK) $(SHELL) $< $(objpfx) \
manual/Makefile:	@if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
nptl/Makefile:	$(SHELL) -e tst-tls6.sh $(common-objpfx) $(elf-objpfx) \
nptl/Makefile:	$(SHELL) $< $(common-objpfx)libc_pic.a \
posix/Makefile:	$(SHELL) -e globtest.sh $(common-objpfx) $(elf-objpfx) \
posix/Makefile:	$(SHELL) -e wordexp-tst.sh $(common-objpfx) $(elf-objpfx) \
posix/Makefile:	$(SHELL) -e $< $(common-objpfx) $(elf-objpfx) $(rtld-installed-name)
stdio-common/Makefile:	$(SHELL) -e tst-unbputc.sh $(common-objpfx) '$(run-program-prefix)'
stdio-common/Makefile:	$(SHELL) -e tst-printf.sh $(common-objpfx) '$(run-program-prefix)'
stdlib/Makefile:	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)stdlib/

> > +echo '# normal mode'
> > +$rtld $rtld 2>&1 && rc=0 || rc=$?
> 
> This is a strange formulation and only necessary because of -e.  I don't
> see what -e is buying you at all. Just drop -e and write:

set -e makes the script exit with a non-zero status if something goes
wrong.  Not the program being tested but something else.  I think
it is a good default behavior for test scripts.

> 	$rtld $rtld 2>&1
> 	test $? -le 127 || result=1

No, the exit status has to be saved anyway because its value is needed for
two different actions: print and test.


-- 
ldv

Attachment: pgp00000.pgp
Description: PGP signature


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