Why Do I Have No Exit Code From debootstrap?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite












I am testing out debootstrap in a chroot via a bash script.



The snippet that runs it is:



#!/usr/bin/env bash
set -e
...
...
sudo debootstrap --verbose --arch=$ARCH $RELEASE $chroot_dir
if [ "$?" -ne "0" ]; then
echo "debootstrap failed."
echo "See $chroot_dir/debootstrap/debootstrap.log for more information."
exit 1
fi

echo "debootstrap succeeded"


However, after running the script the last lines printed to the terminal are:



I: Chosen extractor for .deb packages: dpkg-deb
I: Extracting adduser...


I don't see the failed or the succeeded message.



The debootstrap log in the chroot says:



tar: ./usr/sbin/addgroup: Cannot create symlink to 'adduser': File exists
tar: ./usr/sbin/delgroup: Cannot create symlink to 'deluser': File exists
tar: Exiting with failure status due to previous errors


So clearly something has failed.



Why am I not able to catch this in my error check block?







share|improve this question






















  • Those lines printed to the terminal prefixed with I: are the output of debootstrap and I have output part of the debootstrap log in the question too, so yes, I am sure it has started.
    – opticyclic
    May 3 at 17:26










  • That is interesting. It works as expected. Can you explain in an answer why one works and the other doesn't and what the difference is?
    – opticyclic
    May 3 at 19:29






  • 1




    It was your links that enabled me to search using the right terms for the answer!
    – opticyclic
    May 4 at 19:09














up vote
1
down vote

favorite












I am testing out debootstrap in a chroot via a bash script.



The snippet that runs it is:



#!/usr/bin/env bash
set -e
...
...
sudo debootstrap --verbose --arch=$ARCH $RELEASE $chroot_dir
if [ "$?" -ne "0" ]; then
echo "debootstrap failed."
echo "See $chroot_dir/debootstrap/debootstrap.log for more information."
exit 1
fi

echo "debootstrap succeeded"


However, after running the script the last lines printed to the terminal are:



I: Chosen extractor for .deb packages: dpkg-deb
I: Extracting adduser...


I don't see the failed or the succeeded message.



The debootstrap log in the chroot says:



tar: ./usr/sbin/addgroup: Cannot create symlink to 'adduser': File exists
tar: ./usr/sbin/delgroup: Cannot create symlink to 'deluser': File exists
tar: Exiting with failure status due to previous errors


So clearly something has failed.



Why am I not able to catch this in my error check block?







share|improve this question






















  • Those lines printed to the terminal prefixed with I: are the output of debootstrap and I have output part of the debootstrap log in the question too, so yes, I am sure it has started.
    – opticyclic
    May 3 at 17:26










  • That is interesting. It works as expected. Can you explain in an answer why one works and the other doesn't and what the difference is?
    – opticyclic
    May 3 at 19:29






  • 1




    It was your links that enabled me to search using the right terms for the answer!
    – opticyclic
    May 4 at 19:09












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am testing out debootstrap in a chroot via a bash script.



The snippet that runs it is:



#!/usr/bin/env bash
set -e
...
...
sudo debootstrap --verbose --arch=$ARCH $RELEASE $chroot_dir
if [ "$?" -ne "0" ]; then
echo "debootstrap failed."
echo "See $chroot_dir/debootstrap/debootstrap.log for more information."
exit 1
fi

echo "debootstrap succeeded"


However, after running the script the last lines printed to the terminal are:



I: Chosen extractor for .deb packages: dpkg-deb
I: Extracting adduser...


I don't see the failed or the succeeded message.



The debootstrap log in the chroot says:



tar: ./usr/sbin/addgroup: Cannot create symlink to 'adduser': File exists
tar: ./usr/sbin/delgroup: Cannot create symlink to 'deluser': File exists
tar: Exiting with failure status due to previous errors


So clearly something has failed.



Why am I not able to catch this in my error check block?







share|improve this question














I am testing out debootstrap in a chroot via a bash script.



The snippet that runs it is:



#!/usr/bin/env bash
set -e
...
...
sudo debootstrap --verbose --arch=$ARCH $RELEASE $chroot_dir
if [ "$?" -ne "0" ]; then
echo "debootstrap failed."
echo "See $chroot_dir/debootstrap/debootstrap.log for more information."
exit 1
fi

echo "debootstrap succeeded"


However, after running the script the last lines printed to the terminal are:



I: Chosen extractor for .deb packages: dpkg-deb
I: Extracting adduser...


I don't see the failed or the succeeded message.



The debootstrap log in the chroot says:



tar: ./usr/sbin/addgroup: Cannot create symlink to 'adduser': File exists
tar: ./usr/sbin/delgroup: Cannot create symlink to 'deluser': File exists
tar: Exiting with failure status due to previous errors


So clearly something has failed.



Why am I not able to catch this in my error check block?









share|improve this question













share|improve this question




share|improve this question








edited May 4 at 18:34

























asked May 3 at 17:04









opticyclic

317214




317214











  • Those lines printed to the terminal prefixed with I: are the output of debootstrap and I have output part of the debootstrap log in the question too, so yes, I am sure it has started.
    – opticyclic
    May 3 at 17:26










  • That is interesting. It works as expected. Can you explain in an answer why one works and the other doesn't and what the difference is?
    – opticyclic
    May 3 at 19:29






  • 1




    It was your links that enabled me to search using the right terms for the answer!
    – opticyclic
    May 4 at 19:09
















  • Those lines printed to the terminal prefixed with I: are the output of debootstrap and I have output part of the debootstrap log in the question too, so yes, I am sure it has started.
    – opticyclic
    May 3 at 17:26










  • That is interesting. It works as expected. Can you explain in an answer why one works and the other doesn't and what the difference is?
    – opticyclic
    May 3 at 19:29






  • 1




    It was your links that enabled me to search using the right terms for the answer!
    – opticyclic
    May 4 at 19:09















Those lines printed to the terminal prefixed with I: are the output of debootstrap and I have output part of the debootstrap log in the question too, so yes, I am sure it has started.
– opticyclic
May 3 at 17:26




Those lines printed to the terminal prefixed with I: are the output of debootstrap and I have output part of the debootstrap log in the question too, so yes, I am sure it has started.
– opticyclic
May 3 at 17:26












That is interesting. It works as expected. Can you explain in an answer why one works and the other doesn't and what the difference is?
– opticyclic
May 3 at 19:29




That is interesting. It works as expected. Can you explain in an answer why one works and the other doesn't and what the difference is?
– opticyclic
May 3 at 19:29




1




1




It was your links that enabled me to search using the right terms for the answer!
– opticyclic
May 4 at 19:09




It was your links that enabled me to search using the right terms for the answer!
– opticyclic
May 4 at 19:09










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










If you just want to test for an exit code, bash has the following simple syntax:





if debootstrap --verbose --arch=$ARCH $RELEASE $chroot_dir
then
echo Success
else
echo Failure
fi


The reason why the other way doesn't work is because set -e causes the script to exit before the exit code is tested.



For further reading about exit values and error trapping see the following links:



  • http://mywiki.wooledge.org/BashFAQ/105

  • https://sanctum.geek.nz/arabesque/testing-exit-values-bash/





share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1031639%2fwhy-do-i-have-no-exit-code-from-debootstrap%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    If you just want to test for an exit code, bash has the following simple syntax:





    if debootstrap --verbose --arch=$ARCH $RELEASE $chroot_dir
    then
    echo Success
    else
    echo Failure
    fi


    The reason why the other way doesn't work is because set -e causes the script to exit before the exit code is tested.



    For further reading about exit values and error trapping see the following links:



    • http://mywiki.wooledge.org/BashFAQ/105

    • https://sanctum.geek.nz/arabesque/testing-exit-values-bash/





    share|improve this answer


























      up vote
      1
      down vote



      accepted










      If you just want to test for an exit code, bash has the following simple syntax:





      if debootstrap --verbose --arch=$ARCH $RELEASE $chroot_dir
      then
      echo Success
      else
      echo Failure
      fi


      The reason why the other way doesn't work is because set -e causes the script to exit before the exit code is tested.



      For further reading about exit values and error trapping see the following links:



      • http://mywiki.wooledge.org/BashFAQ/105

      • https://sanctum.geek.nz/arabesque/testing-exit-values-bash/





      share|improve this answer
























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        If you just want to test for an exit code, bash has the following simple syntax:





        if debootstrap --verbose --arch=$ARCH $RELEASE $chroot_dir
        then
        echo Success
        else
        echo Failure
        fi


        The reason why the other way doesn't work is because set -e causes the script to exit before the exit code is tested.



        For further reading about exit values and error trapping see the following links:



        • http://mywiki.wooledge.org/BashFAQ/105

        • https://sanctum.geek.nz/arabesque/testing-exit-values-bash/





        share|improve this answer














        If you just want to test for an exit code, bash has the following simple syntax:





        if debootstrap --verbose --arch=$ARCH $RELEASE $chroot_dir
        then
        echo Success
        else
        echo Failure
        fi


        The reason why the other way doesn't work is because set -e causes the script to exit before the exit code is tested.



        For further reading about exit values and error trapping see the following links:



        • http://mywiki.wooledge.org/BashFAQ/105

        • https://sanctum.geek.nz/arabesque/testing-exit-values-bash/






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 4 at 18:59

























        answered May 3 at 20:35









        dessert

        19.6k55594




        19.6k55594






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1031639%2fwhy-do-i-have-no-exit-code-from-debootstrap%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Which professions warranted travel in Medieval times?

            How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

            Trouble downloading packages list due to a “Hash sum mismatch” error