From: "Dmitry V. Levin" <ldv@altlinux.org> To: Alexey Gladkov <legion@altlinux.org> Cc: ALT Devel discussion list <devel@lists.altlinux.org> Subject: [devel] A: trap shell builtin (was: [SCM] packages/make-initrd: heads/master) Date: Thu, 18 Feb 2010 16:42:54 +0300 Message-ID: <20100218134254.GF11639@wo.int.altlinux.org> (raw) In-Reply-To: <20100218130528.9EDB91D9675A@ssh.git.orion.altlinux.org> [-- Attachment #1: Type: text/plain, Size: 1097 bytes --] On Thu, Feb 18, 2010 at 04:05:28PM +0300, Alexey Gladkov wrote: > Update of /people/legion/packages/make-initrd.git [...] > --- a/make-initrd.in > +++ b/make-initrd.in > @@ -1,4 +1,25 @@ > #!/bin/sh -efu > > +PROG="${0##*/}" > +TEMPDIR= > +term_handler() { > + local rc=$? > + [ -z "$TEMPDIR" ] || rm -rf -- "$TEMPDIR" > + exit $rc > +} > + > +exit_handler() { > + local rc=$? > + trap - EXIT > + [ -z "$TEMPDIR" ] || rmdir -- "$TEMPDIR" 2>/dev/null ||: > + exit $rc > +} > + > + > +TEMPDIR="$(mktemp -d "@TMPDIR@/$PROG.XXXXXXXXX")" > +trap term_handler HUP INT QUIT TERM > +trap exit_handler EXIT Это уже совсем старые грабли: term_handler устанавливает случайный код возврата и удаляет $TEMPDIR дважды. Подробнее на эту тему см. http://lists.gnu.org/archive/html/bug-gnulib/2010-01/msg00361.html http://lists.gnu.org/archive/html/bug-gnulib/2010-01/msg00377.html There is an interesting reading about portability issues related to shell "trap" builtin: http://www.gnu.org/software/hello/manual/autoconf/Limitations-of-Builtins.html#trap -- ldv [-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
parent reply other threads:[~2010-02-18 13:42 UTC|newest] Thread overview: expand[flat|nested] mbox.gz Atom feed [parent not found: <20100218130528.9EDB91D9675A@ssh.git.orion.altlinux.org>]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20100218134254.GF11639@wo.int.altlinux.org \ --to=ldv@altlinux.org \ --cc=devel@lists.altlinux.org \ --cc=legion@altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git