Scriptlets should run with "-e" shell flag

Bug #1707189 reported by James Henstridge
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
High
Sergio Schvezov

Bug Description

As discussed on the forum, scriptlets should run with the "-e" shell flag (i.e. fail if any command returns non zero):

https://forum.snapcraft.io/t/scripting-and-setting-metadata-in-snapcraft/1447/2?u=jamesh

At the moment, if I put something like the following in my snapcraft.yaml, the build will succeed:

    install: |
        command_that_fails
        command_that_succeeds

Execution continues past the first failed command, and the second successful command causes the scriptlet to return 0.

Situations like this almost always indicate a bug, and for the cases where the exit code should be ignored there are work arounds (e.g. run "set +e", or append "||:" to the end of the command).

Tags: scripts
Revision history for this message
Leo Arias (elopio) wrote :

Importance set to high because this has made me dig through tons of logs trying to find the step that failed.

Changed in snapcraft:
status: New → Triaged
importance: Undecided → High
tags: added: scripts
Changed in snapcraft:
assignee: nobody → Sergio Schvezov (sergiusens)
Changed in snapcraft:
milestone: none → 2.35
Changed in snapcraft:
status: Triaged → In Progress
Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Changed in snapcraft:
status: In Progress → Fix Committed
Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.