From: Petr Vorel <pvorel@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: linux-nfs@vger.kernel.org, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/1] generate_lvm_runfile.sh: Fix bashism
Date: Thu, 4 Aug 2022 22:24:30 +0200 [thread overview]
Message-ID: <Yuwq/rrb6iWiRI9A@pevik> (raw)
In-Reply-To: <2fd92c3d-a67e-3cfc-aaf8-ca35176cf399@suse.cz>
Hi Martin,
> Hi,
> `trap ... EXIT` cannot be used to emulate `trap ... ERR`. The latter
> behaves as if every command/pipeline in the script (except conditions)
> were wrapped in ROD. So `trap ... ERR` will trigger exit on any failure,
Ah, thx for info. OK, we also need to add set -e (or #!/bin/sh -e).
Because using ERR would require to change shebang to #!/bin/bash.
Kind regards,
Petr
> while `trap ... EXIT` will let the script continue after all errors and
> then check exit code of only the very last command. That's not what we
> want here.
> On 03. 08. 22 19:57, Petr Vorel wrote:
> > ERR is not on dash (tested on 0.5.11).
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > testcases/misc/lvm/generate_lvm_runfile.sh | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > diff --git a/testcases/misc/lvm/generate_lvm_runfile.sh b/testcases/misc/lvm/generate_lvm_runfile.sh
> > index 72b286a69..5bf5d91d6 100755
> > --- a/testcases/misc/lvm/generate_lvm_runfile.sh
> > +++ b/testcases/misc/lvm/generate_lvm_runfile.sh
> > @@ -13,7 +13,7 @@ LVM_TMPDIR="$LVM_DIR/ltp/growfiles"
> > generate_runfile()
> > {
> > - trap 'tst_brk TBROK "Cannot create LVM runfile"' ERR
> > + trap '[ $? -eq 0 ] && exit 0 || tst_brk TBROK "Cannot create LVM runfile"' EXIT
> > INFILE="$LTPROOT/testcases/data/lvm/runfile.tpl"
> > OUTFILE="$LTPROOT/runtest/lvm.local"
> > FS_LIST=`tst_supported_fs`
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2022-08-04 20:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 17:57 [LTP] [PATCH 1/1] generate_lvm_runfile.sh: Fix bashism Petr Vorel
2022-08-04 15:33 ` Martin Doucha
2022-08-04 20:24 ` Petr Vorel [this message]
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=Yuwq/rrb6iWiRI9A@pevik \
--to=pvorel@suse.cz \
--cc=linux-nfs@vger.kernel.org \
--cc=ltp@lists.linux.it \
--cc=mdoucha@suse.cz \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox