.bashrc is causing git push to fail

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











up vote
0
down vote

favorite












I'm trying to push code using git to my remote server, but I get the error:



fatal: protocol error: bad line length character:
8


I researched this bug and it turns out my .bashrc file that echos out a welcome screen is causing this error. What I would like to do is determine if this is a git push and to NOT display the welcome screen, or only display the screen when logging into SSH with no directory parameter:



ssh user@ssh-server.foo:/deployment/bare-git-repo


Here is the relevant lines in .bashrc:



if [ -e ./.doc ]
then
cat ./.doc
pm2 list
fi


Thanks in advance!







share|improve this question























    up vote
    0
    down vote

    favorite












    I'm trying to push code using git to my remote server, but I get the error:



    fatal: protocol error: bad line length character:
    8


    I researched this bug and it turns out my .bashrc file that echos out a welcome screen is causing this error. What I would like to do is determine if this is a git push and to NOT display the welcome screen, or only display the screen when logging into SSH with no directory parameter:



    ssh user@ssh-server.foo:/deployment/bare-git-repo


    Here is the relevant lines in .bashrc:



    if [ -e ./.doc ]
    then
    cat ./.doc
    pm2 list
    fi


    Thanks in advance!







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to push code using git to my remote server, but I get the error:



      fatal: protocol error: bad line length character:
      8


      I researched this bug and it turns out my .bashrc file that echos out a welcome screen is causing this error. What I would like to do is determine if this is a git push and to NOT display the welcome screen, or only display the screen when logging into SSH with no directory parameter:



      ssh user@ssh-server.foo:/deployment/bare-git-repo


      Here is the relevant lines in .bashrc:



      if [ -e ./.doc ]
      then
      cat ./.doc
      pm2 list
      fi


      Thanks in advance!







      share|improve this question











      I'm trying to push code using git to my remote server, but I get the error:



      fatal: protocol error: bad line length character:
      8


      I researched this bug and it turns out my .bashrc file that echos out a welcome screen is causing this error. What I would like to do is determine if this is a git push and to NOT display the welcome screen, or only display the screen when logging into SSH with no directory parameter:



      ssh user@ssh-server.foo:/deployment/bare-git-repo


      Here is the relevant lines in .bashrc:



      if [ -e ./.doc ]
      then
      cat ./.doc
      pm2 list
      fi


      Thanks in advance!









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jun 22 at 11:54









      mwieczorek

      1032




      1032




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          I don’t think there’s anything specific to git push hooks on the server, that you could use, but you could check whether you’re outputting to a terminal:



          if [ -t 1 ] && [ -e ./.doc ]; then
          cat ./.doc
          pm2 list
          fi


          This will deal with a number of other cases where outputting the contents ./.doc doesn’t serve much purpose and could cause problems.






          share|improve this answer




























            up vote
            1
            down vote













            I suspect what you really want to do, is prevent running things which have no business being run in a non-interactive shell from running.



            A common tactic for this, is to check whether stdin is not attached to a terminal via [[ ! -t 1 ]], or to check whether the bash process is not marked as interactive via [[ $- != *i* ]]. If one of these failure cases evaluates to true, then nothing else in your bashrc should get executed at all, and you should just return early.






            share|improve this answer





















              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%2f451286%2fbashrc-is-causing-git-push-to-fail%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote



              accepted










              I don’t think there’s anything specific to git push hooks on the server, that you could use, but you could check whether you’re outputting to a terminal:



              if [ -t 1 ] && [ -e ./.doc ]; then
              cat ./.doc
              pm2 list
              fi


              This will deal with a number of other cases where outputting the contents ./.doc doesn’t serve much purpose and could cause problems.






              share|improve this answer

























                up vote
                2
                down vote



                accepted










                I don’t think there’s anything specific to git push hooks on the server, that you could use, but you could check whether you’re outputting to a terminal:



                if [ -t 1 ] && [ -e ./.doc ]; then
                cat ./.doc
                pm2 list
                fi


                This will deal with a number of other cases where outputting the contents ./.doc doesn’t serve much purpose and could cause problems.






                share|improve this answer























                  up vote
                  2
                  down vote



                  accepted







                  up vote
                  2
                  down vote



                  accepted






                  I don’t think there’s anything specific to git push hooks on the server, that you could use, but you could check whether you’re outputting to a terminal:



                  if [ -t 1 ] && [ -e ./.doc ]; then
                  cat ./.doc
                  pm2 list
                  fi


                  This will deal with a number of other cases where outputting the contents ./.doc doesn’t serve much purpose and could cause problems.






                  share|improve this answer













                  I don’t think there’s anything specific to git push hooks on the server, that you could use, but you could check whether you’re outputting to a terminal:



                  if [ -t 1 ] && [ -e ./.doc ]; then
                  cat ./.doc
                  pm2 list
                  fi


                  This will deal with a number of other cases where outputting the contents ./.doc doesn’t serve much purpose and could cause problems.







                  share|improve this answer













                  share|improve this answer



                  share|improve this answer











                  answered Jun 22 at 12:39









                  Stephen Kitt

                  139k22299361




                  139k22299361






















                      up vote
                      1
                      down vote













                      I suspect what you really want to do, is prevent running things which have no business being run in a non-interactive shell from running.



                      A common tactic for this, is to check whether stdin is not attached to a terminal via [[ ! -t 1 ]], or to check whether the bash process is not marked as interactive via [[ $- != *i* ]]. If one of these failure cases evaluates to true, then nothing else in your bashrc should get executed at all, and you should just return early.






                      share|improve this answer

























                        up vote
                        1
                        down vote













                        I suspect what you really want to do, is prevent running things which have no business being run in a non-interactive shell from running.



                        A common tactic for this, is to check whether stdin is not attached to a terminal via [[ ! -t 1 ]], or to check whether the bash process is not marked as interactive via [[ $- != *i* ]]. If one of these failure cases evaluates to true, then nothing else in your bashrc should get executed at all, and you should just return early.






                        share|improve this answer























                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          I suspect what you really want to do, is prevent running things which have no business being run in a non-interactive shell from running.



                          A common tactic for this, is to check whether stdin is not attached to a terminal via [[ ! -t 1 ]], or to check whether the bash process is not marked as interactive via [[ $- != *i* ]]. If one of these failure cases evaluates to true, then nothing else in your bashrc should get executed at all, and you should just return early.






                          share|improve this answer













                          I suspect what you really want to do, is prevent running things which have no business being run in a non-interactive shell from running.



                          A common tactic for this, is to check whether stdin is not attached to a terminal via [[ ! -t 1 ]], or to check whether the bash process is not marked as interactive via [[ $- != *i* ]]. If one of these failure cases evaluates to true, then nothing else in your bashrc should get executed at all, and you should just return early.







                          share|improve this answer













                          share|improve this answer



                          share|improve this answer











                          answered Jun 22 at 13:23









                          eschwartz

                          1016




                          1016






















                               

                              draft saved


                              draft discarded


























                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451286%2fbashrc-is-causing-git-push-to-fail%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Popular posts from this blog

                              Peggy Mitchell

                              Palaiologos

                              The Forum (Inglewood, California)