bash script debug output + and ++

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











up vote
0
down vote

favorite












What are / is the significance of + and ++ at the beginning of bash debug (set -x) output?



The original text looks like this



++ delete 
+ exitstatus=0
+ '[' 0 = 0 ']'
++ delete
+ whiptail --title 'Command output 1311' --separate-output --scrolltext --msgbox '/usr/bin/raspi-config-DEBUG.sh: line 1311: delete: command not found' 17 80 10
+ echo '1317 done printing choice to stdout'









share|improve this question



























    up vote
    0
    down vote

    favorite












    What are / is the significance of + and ++ at the beginning of bash debug (set -x) output?



    The original text looks like this



    ++ delete 
    + exitstatus=0
    + '[' 0 = 0 ']'
    ++ delete
    + whiptail --title 'Command output 1311' --separate-output --scrolltext --msgbox '/usr/bin/raspi-config-DEBUG.sh: line 1311: delete: command not found' 17 80 10
    + echo '1317 done printing choice to stdout'









    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      What are / is the significance of + and ++ at the beginning of bash debug (set -x) output?



      The original text looks like this



      ++ delete 
      + exitstatus=0
      + '[' 0 = 0 ']'
      ++ delete
      + whiptail --title 'Command output 1311' --separate-output --scrolltext --msgbox '/usr/bin/raspi-config-DEBUG.sh: line 1311: delete: command not found' 17 80 10
      + echo '1317 done printing choice to stdout'









      share|improve this question















      What are / is the significance of + and ++ at the beginning of bash debug (set -x) output?



      The original text looks like this



      ++ delete 
      + exitstatus=0
      + '[' 0 = 0 ']'
      ++ delete
      + whiptail --title 'Command output 1311' --separate-output --scrolltext --msgbox '/usr/bin/raspi-config-DEBUG.sh: line 1311: delete: command not found' 17 80 10
      + echo '1317 done printing choice to stdout'






      shell-script






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 13 at 15:13









      Kusalananda

      107k14209331




      107k14209331










      asked Sep 13 at 15:09









      Jan Hus

      1446




      1446




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          6
          down vote



          accepted










          The + is the PS4 prompt (just like PS1 usually holds $ or some variation thereof, which is the default interactive prompt). It is outputted before each command executed when tracing is enabled with set -x.



          The bash manual says this:




          PS4



          The value of this parameter is expanded as with PS1 and the
          value is printed before each command bash displays during an
          execution trace. The first character of PS4 is replicated
          multiple times, as necessary, to indicate multiple levels of
          indirection. The default is +.




          The multiple + that you may see are due to commands being executed in subshells.



          Example showing three levels of subshells:



          $ cat script.sh
          #!/bin/bash

          echo "$( echo "$( echo hi )" )"




          $ bash -x script.sh
          +++ echo hi
          ++ echo hi
          + echo hi
          hi





          share|improve this answer






















          • Great, now for the formatting part - how was it reformatted to look as original text, for future references.
            – Jan Hus
            Sep 13 at 15:35






          • 1




            @JanHus You can't reformat it to get the original shell script back. In my example, there is no information that tells me exactly what the original commands looked like.
            – Kusalananda
            Sep 13 at 15:39










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f468822%2fbash-script-debug-output-and%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
          6
          down vote



          accepted










          The + is the PS4 prompt (just like PS1 usually holds $ or some variation thereof, which is the default interactive prompt). It is outputted before each command executed when tracing is enabled with set -x.



          The bash manual says this:




          PS4



          The value of this parameter is expanded as with PS1 and the
          value is printed before each command bash displays during an
          execution trace. The first character of PS4 is replicated
          multiple times, as necessary, to indicate multiple levels of
          indirection. The default is +.




          The multiple + that you may see are due to commands being executed in subshells.



          Example showing three levels of subshells:



          $ cat script.sh
          #!/bin/bash

          echo "$( echo "$( echo hi )" )"




          $ bash -x script.sh
          +++ echo hi
          ++ echo hi
          + echo hi
          hi





          share|improve this answer






















          • Great, now for the formatting part - how was it reformatted to look as original text, for future references.
            – Jan Hus
            Sep 13 at 15:35






          • 1




            @JanHus You can't reformat it to get the original shell script back. In my example, there is no information that tells me exactly what the original commands looked like.
            – Kusalananda
            Sep 13 at 15:39














          up vote
          6
          down vote



          accepted










          The + is the PS4 prompt (just like PS1 usually holds $ or some variation thereof, which is the default interactive prompt). It is outputted before each command executed when tracing is enabled with set -x.



          The bash manual says this:




          PS4



          The value of this parameter is expanded as with PS1 and the
          value is printed before each command bash displays during an
          execution trace. The first character of PS4 is replicated
          multiple times, as necessary, to indicate multiple levels of
          indirection. The default is +.




          The multiple + that you may see are due to commands being executed in subshells.



          Example showing three levels of subshells:



          $ cat script.sh
          #!/bin/bash

          echo "$( echo "$( echo hi )" )"




          $ bash -x script.sh
          +++ echo hi
          ++ echo hi
          + echo hi
          hi





          share|improve this answer






















          • Great, now for the formatting part - how was it reformatted to look as original text, for future references.
            – Jan Hus
            Sep 13 at 15:35






          • 1




            @JanHus You can't reformat it to get the original shell script back. In my example, there is no information that tells me exactly what the original commands looked like.
            – Kusalananda
            Sep 13 at 15:39












          up vote
          6
          down vote



          accepted







          up vote
          6
          down vote



          accepted






          The + is the PS4 prompt (just like PS1 usually holds $ or some variation thereof, which is the default interactive prompt). It is outputted before each command executed when tracing is enabled with set -x.



          The bash manual says this:




          PS4



          The value of this parameter is expanded as with PS1 and the
          value is printed before each command bash displays during an
          execution trace. The first character of PS4 is replicated
          multiple times, as necessary, to indicate multiple levels of
          indirection. The default is +.




          The multiple + that you may see are due to commands being executed in subshells.



          Example showing three levels of subshells:



          $ cat script.sh
          #!/bin/bash

          echo "$( echo "$( echo hi )" )"




          $ bash -x script.sh
          +++ echo hi
          ++ echo hi
          + echo hi
          hi





          share|improve this answer














          The + is the PS4 prompt (just like PS1 usually holds $ or some variation thereof, which is the default interactive prompt). It is outputted before each command executed when tracing is enabled with set -x.



          The bash manual says this:




          PS4



          The value of this parameter is expanded as with PS1 and the
          value is printed before each command bash displays during an
          execution trace. The first character of PS4 is replicated
          multiple times, as necessary, to indicate multiple levels of
          indirection. The default is +.




          The multiple + that you may see are due to commands being executed in subshells.



          Example showing three levels of subshells:



          $ cat script.sh
          #!/bin/bash

          echo "$( echo "$( echo hi )" )"




          $ bash -x script.sh
          +++ echo hi
          ++ echo hi
          + echo hi
          hi






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Sep 13 at 15:32

























          answered Sep 13 at 15:16









          Kusalananda

          107k14209331




          107k14209331











          • Great, now for the formatting part - how was it reformatted to look as original text, for future references.
            – Jan Hus
            Sep 13 at 15:35






          • 1




            @JanHus You can't reformat it to get the original shell script back. In my example, there is no information that tells me exactly what the original commands looked like.
            – Kusalananda
            Sep 13 at 15:39
















          • Great, now for the formatting part - how was it reformatted to look as original text, for future references.
            – Jan Hus
            Sep 13 at 15:35






          • 1




            @JanHus You can't reformat it to get the original shell script back. In my example, there is no information that tells me exactly what the original commands looked like.
            – Kusalananda
            Sep 13 at 15:39















          Great, now for the formatting part - how was it reformatted to look as original text, for future references.
          – Jan Hus
          Sep 13 at 15:35




          Great, now for the formatting part - how was it reformatted to look as original text, for future references.
          – Jan Hus
          Sep 13 at 15:35




          1




          1




          @JanHus You can't reformat it to get the original shell script back. In my example, there is no information that tells me exactly what the original commands looked like.
          – Kusalananda
          Sep 13 at 15:39




          @JanHus You can't reformat it to get the original shell script back. In my example, there is no information that tells me exactly what the original commands looked like.
          – Kusalananda
          Sep 13 at 15:39

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468822%2fbash-script-debug-output-and%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay