Merge lp://qastaging/~liuyq0307/lava-master-image-scripts/fix-trap-on-exit into lp://qastaging/lava-master-image-scripts

Proposed by Yongqin Liu
Status: Merged
Merged at revision: 63
Proposed branch: lp://qastaging/~liuyq0307/lava-master-image-scripts/fix-trap-on-exit
Merge into: lp://qastaging/lava-master-image-scripts
Diff against target: 12 lines (+1/-1)
1 file modified
lava-create-master (+1/-1)
To merge this branch: bzr merge lp://qastaging/~liuyq0307/lava-master-image-scripts/fix-trap-on-exit
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle (community) Approve
Review via email: mp+112703@code.qastaging.launchpad.net

Description of the change

add the "-" arg for trap on EXIT

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

A comment of why this is needed would be nice

Revision history for this message
Andy Doan (doanac) wrote :

agree with zygmunt. otherwise it seems fine

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

This is really odd. The lava-create-master script is a /bin/sh script, not a /bin/bash script so the bash version is irrelevant, but even dash should support "trap EXIT" if I read its man page correctly (and my tests support this).

That said, I'd support landing this patch and/or converting the script to invoke /bin/bash instead.

review: Approve
Revision history for this message
Yongqin Liu (liuyq0307) wrote :

In my environment, both bash and dash have the same error.
I guess there are some changes in the implementation of trap.
But trap is actually a built-in of bash or dash.
I don't know what is the real reason, but with the "-" argument it works for me.

14:08:46 liuyq:lava-master-image-scripts$ ./lava-create-master panda
LAVA master images are easy to make, just three steps:
Note: run with --verbose to see details

1) Preparing vanilla Linaro image
2) Converting vanilla image to LAVA master image
add map loop0p1 (253:0): 0 106496 linear /dev/loop0 8192
add map loop0p2 (253:1): 0 1982464 linear /dev/loop0 114688
trap: usage: trap [-lp] [[arg] signal_spec ...]
./lava-create-master: line 1: 18394 Terminated udisks --inhibit > /dev/null 2>&1
umount: /tmp/tmp.pLLTJFi1bQ.lava.panda.master: not found

14:09:04 liuyq:lava-master-image-scripts$ dash ./lava-create-master panda
LAVA master images are easy to make, just three steps:
Note: run with --verbose to see details

1) Preparing vanilla Linaro image
2) Converting vanilla image to LAVA master image
add map loop0p1 (253:0): 0 106496 linear /dev/loop0 8192
add map loop0p2 (253:1): 0 1982464 linear /dev/loop0 114688
trap: usage: trap [-lp] [[arg] signal_spec ...]
./lava-create-master: line 1: 18526 Terminated udisks --inhibit > /dev/null 2>&1
umount: /tmp/tmp.HfCnoniGT9.lava.panda.master: not found

14:09:23 liuyq:lava-master-image-scripts$ bash ./lava-create-master panda
LAVA master images are easy to make, just three steps:
Note: run with --verbose to see details

1) Preparing vanilla Linaro image
2) Converting vanilla image to LAVA master image
add map loop0p1 (253:0): 0 106496 linear /dev/loop0 8192
add map loop0p2 (253:1): 0 1982464 linear /dev/loop0 114688
trap: usage: trap [-lp] [[arg] signal_spec ...]
./lava-create-master: line 1: 18653 Terminated udisks --inhibit > /dev/null 2>&1
umount: /tmp/tmp.IVqlTEWDJK.lava.panda.master: not found
14:09:38 liuyq:lava-master-image-scripts$

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

and the trap without "-" argument version did work for me several days before.
don't know what change is done during those days.

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

$ /bin/sh -c "trap EXIT"
trap: usage: trap [-lp] [[arg] signal_spec ...]
$ bash -c "trap EXIT"
$ dash -c "trap EXIT"
$ ll /bin/sh
lrwxrwxrwx 1 root root 9 6月 25 13:37 /bin/sh -> /bin/bash*
$ trap EXIT
$

seems only the sh link has problems

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Yongqin Liu <email address hidden> writes:

> $ /bin/sh -c "trap EXIT"
> trap: usage: trap [-lp] [[arg] signal_spec ...]
> $ bash -c "trap EXIT"
> $ dash -c "trap EXIT"
> $ ll /bin/sh
> lrwxrwxrwx 1 root root 9 6月 25 13:37 /bin/sh -> /bin/bash*
> $ trap EXIT
> $
>
> seems only the sh link has problems

Hah, so I can reproduce this:

mwhudson@narsil:devel$ ln -s /bin/bash ~/bin/sh
mwhudson@narsil:devel$ ~/bin/sh -c "trap EXIT"
trap: usage: trap [-lp] [[arg] signal_spec ...]

A bug in bash's bourne shell mode or something?

Anyway, please merge this branch.

Cheers,
mwh

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches