“__bp_preexec_invoke_exec: No such file or directory” when using $_












2














I am trying to create a new directory and simultaneously switch to it in one line command on Bash using mkdir repo && cd $_. This has worked well for me previously on all Linux distros but now when I try it on Elementary OS 5 it throws me the below error:



:~$ mkdir repo && cd $_
bash: cd: __bp_preexec_invoke_exec: No such file or directory


Is this a Bash problem? How can we fix this?










share|improve this question





























    2














    I am trying to create a new directory and simultaneously switch to it in one line command on Bash using mkdir repo && cd $_. This has worked well for me previously on all Linux distros but now when I try it on Elementary OS 5 it throws me the below error:



    :~$ mkdir repo && cd $_
    bash: cd: __bp_preexec_invoke_exec: No such file or directory


    Is this a Bash problem? How can we fix this?










    share|improve this question



























      2












      2








      2







      I am trying to create a new directory and simultaneously switch to it in one line command on Bash using mkdir repo && cd $_. This has worked well for me previously on all Linux distros but now when I try it on Elementary OS 5 it throws me the below error:



      :~$ mkdir repo && cd $_
      bash: cd: __bp_preexec_invoke_exec: No such file or directory


      Is this a Bash problem? How can we fix this?










      share|improve this question















      I am trying to create a new directory and simultaneously switch to it in one line command on Bash using mkdir repo && cd $_. This has worked well for me previously on all Linux distros but now when I try it on Elementary OS 5 it throws me the below error:



      :~$ mkdir repo && cd $_
      bash: cd: __bp_preexec_invoke_exec: No such file or directory


      Is this a Bash problem? How can we fix this?







      linux bash






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 10 at 17:06









      Kamil Maciorowski

      24.2k155176




      24.2k155176










      asked Dec 10 at 16:02









      Siddhant Swami

      133




      133






















          1 Answer
          1






          active

          oldest

          votes


















          1














          This is not a problem of sole Bash.



          My guess is something (a terminal emulator?) integrates with Bash, defines __bp_preexec_invoke_exec function and sets a DEBUG trap that uses this function.



          There is a question on SO: bash: preserve $_ in a DEBUG trap. From therein:




          When using a DEBUG trap, $_ is based upon the last command run by the trap […] rather than the last command the user entered




          The answer:




          It's worth noting that "the last argument of the last command executed" includes the literal text "last command executed", not "last command entered by the user"; bash is behaving as its documentation promises in this respect.



          But never mind that: Unless your traps are ever returning nonzero values (and thus aborting commands they run before), this is easy enough to work around:



          trapfunc() { local old_=$1; date; : "$old_"; }
          trap 'trapfunc "$_"' DEBUG



          For example take iTerm2. It uses __bp_preexec_invoke_exec (note in your particular case it may be some other program that uses the same name for the same purpose). At the moment I'm writing this answer, this is what you can find under https://iterm2.com/shell_integration/bash :




          # This function is installed as the DEBUG trap.  It is invoked before each
          # interactive prompt display. Its purpose is to inspect the current
          # environment to attempt to detect if the current command is being invoked
          # interactively, and invoke 'preexec' if so.
          __bp_preexec_invoke_exec() {
          # Save the contents of $_ so that it can be restored later on.
          # https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702
          __bp_last_argument_prev_command="$1"



          The function continues and then




          __bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command"


          }




          And elsewhere (__bp_install):




          trap '__bp_preexec_invoke_exec "$_"' DEBUG



          So it basically uses the solution from the linked answer. Note the code even mentions the linked question!



          You should find out where your __bp_preexec_invoke_exec comes from and patch it accordingly along with probable trap '__bp_preexec_invoke_exec' DEBUG line. Or maybe the software that is the culprit has already been patched and you only need to update.






          share|improve this answer





















          • Thanks for such an elaborate answer Kamil!! I just took the trapfunc() you have written above and pasted it in my .bashrc and it works like a charm. Just wanted to ask why have you used date command in your trapfunc? Keeping it in trapfunc makes the date printed out on execution of any command.
            – Siddhant Swami
            Dec 11 at 5:18










          • @SiddhantSwami First, it's not my function; it's a part of the quote from the linked answer and date was used in the question there. Second, it's just an example anyway.
            – Kamil Maciorowski
            Dec 11 at 6:04











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1382360%2fbp-preexec-invoke-exec-no-such-file-or-directory-when-using%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          This is not a problem of sole Bash.



          My guess is something (a terminal emulator?) integrates with Bash, defines __bp_preexec_invoke_exec function and sets a DEBUG trap that uses this function.



          There is a question on SO: bash: preserve $_ in a DEBUG trap. From therein:




          When using a DEBUG trap, $_ is based upon the last command run by the trap […] rather than the last command the user entered




          The answer:




          It's worth noting that "the last argument of the last command executed" includes the literal text "last command executed", not "last command entered by the user"; bash is behaving as its documentation promises in this respect.



          But never mind that: Unless your traps are ever returning nonzero values (and thus aborting commands they run before), this is easy enough to work around:



          trapfunc() { local old_=$1; date; : "$old_"; }
          trap 'trapfunc "$_"' DEBUG



          For example take iTerm2. It uses __bp_preexec_invoke_exec (note in your particular case it may be some other program that uses the same name for the same purpose). At the moment I'm writing this answer, this is what you can find under https://iterm2.com/shell_integration/bash :




          # This function is installed as the DEBUG trap.  It is invoked before each
          # interactive prompt display. Its purpose is to inspect the current
          # environment to attempt to detect if the current command is being invoked
          # interactively, and invoke 'preexec' if so.
          __bp_preexec_invoke_exec() {
          # Save the contents of $_ so that it can be restored later on.
          # https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702
          __bp_last_argument_prev_command="$1"



          The function continues and then




          __bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command"


          }




          And elsewhere (__bp_install):




          trap '__bp_preexec_invoke_exec "$_"' DEBUG



          So it basically uses the solution from the linked answer. Note the code even mentions the linked question!



          You should find out where your __bp_preexec_invoke_exec comes from and patch it accordingly along with probable trap '__bp_preexec_invoke_exec' DEBUG line. Or maybe the software that is the culprit has already been patched and you only need to update.






          share|improve this answer





















          • Thanks for such an elaborate answer Kamil!! I just took the trapfunc() you have written above and pasted it in my .bashrc and it works like a charm. Just wanted to ask why have you used date command in your trapfunc? Keeping it in trapfunc makes the date printed out on execution of any command.
            – Siddhant Swami
            Dec 11 at 5:18










          • @SiddhantSwami First, it's not my function; it's a part of the quote from the linked answer and date was used in the question there. Second, it's just an example anyway.
            – Kamil Maciorowski
            Dec 11 at 6:04
















          1














          This is not a problem of sole Bash.



          My guess is something (a terminal emulator?) integrates with Bash, defines __bp_preexec_invoke_exec function and sets a DEBUG trap that uses this function.



          There is a question on SO: bash: preserve $_ in a DEBUG trap. From therein:




          When using a DEBUG trap, $_ is based upon the last command run by the trap […] rather than the last command the user entered




          The answer:




          It's worth noting that "the last argument of the last command executed" includes the literal text "last command executed", not "last command entered by the user"; bash is behaving as its documentation promises in this respect.



          But never mind that: Unless your traps are ever returning nonzero values (and thus aborting commands they run before), this is easy enough to work around:



          trapfunc() { local old_=$1; date; : "$old_"; }
          trap 'trapfunc "$_"' DEBUG



          For example take iTerm2. It uses __bp_preexec_invoke_exec (note in your particular case it may be some other program that uses the same name for the same purpose). At the moment I'm writing this answer, this is what you can find under https://iterm2.com/shell_integration/bash :




          # This function is installed as the DEBUG trap.  It is invoked before each
          # interactive prompt display. Its purpose is to inspect the current
          # environment to attempt to detect if the current command is being invoked
          # interactively, and invoke 'preexec' if so.
          __bp_preexec_invoke_exec() {
          # Save the contents of $_ so that it can be restored later on.
          # https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702
          __bp_last_argument_prev_command="$1"



          The function continues and then




          __bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command"


          }




          And elsewhere (__bp_install):




          trap '__bp_preexec_invoke_exec "$_"' DEBUG



          So it basically uses the solution from the linked answer. Note the code even mentions the linked question!



          You should find out where your __bp_preexec_invoke_exec comes from and patch it accordingly along with probable trap '__bp_preexec_invoke_exec' DEBUG line. Or maybe the software that is the culprit has already been patched and you only need to update.






          share|improve this answer





















          • Thanks for such an elaborate answer Kamil!! I just took the trapfunc() you have written above and pasted it in my .bashrc and it works like a charm. Just wanted to ask why have you used date command in your trapfunc? Keeping it in trapfunc makes the date printed out on execution of any command.
            – Siddhant Swami
            Dec 11 at 5:18










          • @SiddhantSwami First, it's not my function; it's a part of the quote from the linked answer and date was used in the question there. Second, it's just an example anyway.
            – Kamil Maciorowski
            Dec 11 at 6:04














          1












          1








          1






          This is not a problem of sole Bash.



          My guess is something (a terminal emulator?) integrates with Bash, defines __bp_preexec_invoke_exec function and sets a DEBUG trap that uses this function.



          There is a question on SO: bash: preserve $_ in a DEBUG trap. From therein:




          When using a DEBUG trap, $_ is based upon the last command run by the trap […] rather than the last command the user entered




          The answer:




          It's worth noting that "the last argument of the last command executed" includes the literal text "last command executed", not "last command entered by the user"; bash is behaving as its documentation promises in this respect.



          But never mind that: Unless your traps are ever returning nonzero values (and thus aborting commands they run before), this is easy enough to work around:



          trapfunc() { local old_=$1; date; : "$old_"; }
          trap 'trapfunc "$_"' DEBUG



          For example take iTerm2. It uses __bp_preexec_invoke_exec (note in your particular case it may be some other program that uses the same name for the same purpose). At the moment I'm writing this answer, this is what you can find under https://iterm2.com/shell_integration/bash :




          # This function is installed as the DEBUG trap.  It is invoked before each
          # interactive prompt display. Its purpose is to inspect the current
          # environment to attempt to detect if the current command is being invoked
          # interactively, and invoke 'preexec' if so.
          __bp_preexec_invoke_exec() {
          # Save the contents of $_ so that it can be restored later on.
          # https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702
          __bp_last_argument_prev_command="$1"



          The function continues and then




          __bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command"


          }




          And elsewhere (__bp_install):




          trap '__bp_preexec_invoke_exec "$_"' DEBUG



          So it basically uses the solution from the linked answer. Note the code even mentions the linked question!



          You should find out where your __bp_preexec_invoke_exec comes from and patch it accordingly along with probable trap '__bp_preexec_invoke_exec' DEBUG line. Or maybe the software that is the culprit has already been patched and you only need to update.






          share|improve this answer












          This is not a problem of sole Bash.



          My guess is something (a terminal emulator?) integrates with Bash, defines __bp_preexec_invoke_exec function and sets a DEBUG trap that uses this function.



          There is a question on SO: bash: preserve $_ in a DEBUG trap. From therein:




          When using a DEBUG trap, $_ is based upon the last command run by the trap […] rather than the last command the user entered




          The answer:




          It's worth noting that "the last argument of the last command executed" includes the literal text "last command executed", not "last command entered by the user"; bash is behaving as its documentation promises in this respect.



          But never mind that: Unless your traps are ever returning nonzero values (and thus aborting commands they run before), this is easy enough to work around:



          trapfunc() { local old_=$1; date; : "$old_"; }
          trap 'trapfunc "$_"' DEBUG



          For example take iTerm2. It uses __bp_preexec_invoke_exec (note in your particular case it may be some other program that uses the same name for the same purpose). At the moment I'm writing this answer, this is what you can find under https://iterm2.com/shell_integration/bash :




          # This function is installed as the DEBUG trap.  It is invoked before each
          # interactive prompt display. Its purpose is to inspect the current
          # environment to attempt to detect if the current command is being invoked
          # interactively, and invoke 'preexec' if so.
          __bp_preexec_invoke_exec() {
          # Save the contents of $_ so that it can be restored later on.
          # https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702
          __bp_last_argument_prev_command="$1"



          The function continues and then




          __bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command"


          }




          And elsewhere (__bp_install):




          trap '__bp_preexec_invoke_exec "$_"' DEBUG



          So it basically uses the solution from the linked answer. Note the code even mentions the linked question!



          You should find out where your __bp_preexec_invoke_exec comes from and patch it accordingly along with probable trap '__bp_preexec_invoke_exec' DEBUG line. Or maybe the software that is the culprit has already been patched and you only need to update.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 10 at 17:01









          Kamil Maciorowski

          24.2k155176




          24.2k155176












          • Thanks for such an elaborate answer Kamil!! I just took the trapfunc() you have written above and pasted it in my .bashrc and it works like a charm. Just wanted to ask why have you used date command in your trapfunc? Keeping it in trapfunc makes the date printed out on execution of any command.
            – Siddhant Swami
            Dec 11 at 5:18










          • @SiddhantSwami First, it's not my function; it's a part of the quote from the linked answer and date was used in the question there. Second, it's just an example anyway.
            – Kamil Maciorowski
            Dec 11 at 6:04


















          • Thanks for such an elaborate answer Kamil!! I just took the trapfunc() you have written above and pasted it in my .bashrc and it works like a charm. Just wanted to ask why have you used date command in your trapfunc? Keeping it in trapfunc makes the date printed out on execution of any command.
            – Siddhant Swami
            Dec 11 at 5:18










          • @SiddhantSwami First, it's not my function; it's a part of the quote from the linked answer and date was used in the question there. Second, it's just an example anyway.
            – Kamil Maciorowski
            Dec 11 at 6:04
















          Thanks for such an elaborate answer Kamil!! I just took the trapfunc() you have written above and pasted it in my .bashrc and it works like a charm. Just wanted to ask why have you used date command in your trapfunc? Keeping it in trapfunc makes the date printed out on execution of any command.
          – Siddhant Swami
          Dec 11 at 5:18




          Thanks for such an elaborate answer Kamil!! I just took the trapfunc() you have written above and pasted it in my .bashrc and it works like a charm. Just wanted to ask why have you used date command in your trapfunc? Keeping it in trapfunc makes the date printed out on execution of any command.
          – Siddhant Swami
          Dec 11 at 5:18












          @SiddhantSwami First, it's not my function; it's a part of the quote from the linked answer and date was used in the question there. Second, it's just an example anyway.
          – Kamil Maciorowski
          Dec 11 at 6:04




          @SiddhantSwami First, it's not my function; it's a part of the quote from the linked answer and date was used in the question there. Second, it's just an example anyway.
          – Kamil Maciorowski
          Dec 11 at 6:04


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1382360%2fbp-preexec-invoke-exec-no-such-file-or-directory-when-using%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          If I really need a card on my start hand, how many mulligans make sense? [duplicate]

          Alcedinidae

          Can an atomic nucleus contain both particles and antiparticles? [duplicate]