Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MacOs][Bug][Terminal] sed: illegal option -- r before executing commands #159864

Closed
FaberVitale opened this issue Sep 2, 2022 · 32 comments · Fixed by #160209
Closed

[MacOs][Bug][Terminal] sed: illegal option -- r before executing commands #159864

FaberVitale opened this issue Sep 2, 2022 · 32 comments · Fixed by #160209
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release terminal-shell-bash An issue in the terminal specific to bash terminal-shell-integration Shell integration, command decorations, etc. verified Verification succeeded

Comments

@FaberVitale
Copy link

FaberVitale commented Sep 2, 2022

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.71.0 - 784b0177c56c607789f9638da7b6bf3230d47a8c
  • OS Version: macOS 10.15.7
  System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 192.07 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 14.20.0 - ~/.nvm/versions/node/v14.20.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 6.14.17 - ~/.nvm/versions/node/v14.20.0/bin/npm

Steps to Reproduce:

  1. Open the integrated terminal, then select the Terminal tab.
  2. open a new terminal using bash.
  3. The following message appears before executing every command:
sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]

Example

$ echo 'hi'
sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
hi

It's likely that this issue is caused by e55863c#diff-3d4a2862d6125445f81871e00c3b6d60fa24ef567bdf20c2a185f151a1f86129R125

@stessaris
Copy link

stessaris commented Sep 2, 2022

The problem is indeed the sed -r in

__vsc_current_command="$(builtin history 1 | sed -r 's/ *[0-9]+ +//')"

I guess that the fix should be to use just sed and Basic Regular Expressions. The command should be:
s/ *[0-9][0-9]* *//
(two spaces before the last *).

@wonderfan
Copy link

wonderfan commented Sep 5, 2022

Same issue at my side.

@mouday
Copy link

mouday commented Sep 6, 2022

me too! has this problem

@kskliemo
Copy link

kskliemo commented Sep 6, 2022

@Tyriar Tyriar closed this as completed Sep 6, 2022
@Tyriar Tyriar reopened this Sep 6, 2022
@VSCodeTriageBot VSCodeTriageBot added the *duplicate Issue identified as a duplicate of another issue(s) label Sep 6, 2022
@Tyriar Tyriar added this to the August 2022 Recovery 1 milestone Sep 6, 2022
@Tyriar Tyriar self-assigned this Sep 6, 2022
@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release terminal-shell-integration Shell integration, command decorations, etc. terminal-shell-bash An issue in the terminal specific to bash and removed *duplicate Issue identified as a duplicate of another issue(s) labels Sep 6, 2022
@VSCodeTriageBot
Copy link
Collaborator

VSCodeTriageBot commented Sep 6, 2022

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for similar existing issues. See also our issue reporting guidelines.

Happy Coding!

@VSCodeTriageBot VSCodeTriageBot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2022
@Tyriar Tyriar reopened this Sep 6, 2022
@mostafa-yasen
Copy link

mostafa-yasen commented Sep 6, 2022

Any update on this?

I also have the same issue.

@Tyriar
Copy link
Member

Tyriar commented Sep 6, 2022

@mostafa-yasen a fix should come in v1.71.1 within the week

@erikvlarsson
Copy link

erikvlarsson commented Sep 10, 2022

sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]

Having the exact same issue.

@Ndibale
Copy link

Ndibale commented Sep 10, 2022

Should i write the whole code as you typed? Should i put in users directory or where?
The error that comes to my computer is: "sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]"

@EliasOPrado
Copy link

EliasOPrado commented Sep 12, 2022

sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]

@Tyriar Tyriar reopened this Sep 12, 2022
@VSCodeTriageBot VSCodeTriageBot removed the insiders-released Patch has been released in VS Code Insiders label Sep 12, 2022
@Tyriar
Copy link
Member

Tyriar commented Sep 12, 2022

The fix for this is coming in 1.71.2, not sure on the release date currently.

@daiyam
Copy link
Contributor

daiyam commented Sep 12, 2022

In the meantime, you can use the setting "terminal.integrated.shellIntegration.enabled": false, to disable those freaking errors

@niloct
Copy link

niloct commented Sep 12, 2022

The solution is to edit the file /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh on line 125 and use the -E flag instead of -r (since both serve the same purpose - enable use of extended regular expressions - on linux). On Mac -r is not a valid option, hence the issue.

(i.e.:)
__vsc_current_command="$(builtin history 1 | sed -E 's/ *[0-9]+ +//')"

@azhuravlev1001
Copy link

azhuravlev1001 commented Sep 12, 2022

The solution is to edit the file /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh on line 125 and use the -E flag instead of -r (since both serve the same purpose - enable use of extended regular expressions - on linux). On Mac -r is not a valid option, hence the issue.

(i.e.:) __vsc_current_command="$(builtin history 1 | sed -E 's/ *[0-9]+ +//')"

OK well done thank you

@niloct
Copy link

niloct commented Sep 12, 2022

OK well done thank you

You're welcome :)

@digiworkzone
Copy link

digiworkzone commented Sep 13, 2022

worked!!!
thanks

@davigermano25
Copy link

davigermano25 commented Sep 13, 2022

worked

@aromatic-toast
Copy link

aromatic-toast commented Sep 13, 2022

This worked for me as well! Thank you so much!!!!!!!! This error was incredibly annoying!

@fu-mix
Copy link

fu-mix commented Sep 13, 2022

worked well!!
Thank you so much!

@psparacino
Copy link

psparacino commented Sep 13, 2022

Fantastic!

@angizerep
Copy link

angizerep commented Sep 13, 2022

Thank you so much!! It's worked on my machine.

@Tyriar Tyriar closed this as completed Sep 13, 2022
@niloct
Copy link

niloct commented Sep 13, 2022

Glad that it helped you guys :)

@mouday
Copy link

mouday commented Sep 14, 2022

thank you, it worked!

@olliequ
Copy link

olliequ commented Sep 14, 2022

Still getting this problem on MacOS 10.14.6.

Any ETD for patch release?

Incredibly annoying. It's funny because this was a rare time where I decided out the blue to update to the latest version of VSCode.

@firmnardians
Copy link

firmnardians commented Sep 14, 2022

The solution is to edit the file /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh on line 125 and use the -E flag instead of -r (since both serve the same purpose - enable use of extended regular expressions - on linux). On Mac -r is not a valid option, hence the issue.
(i.e.:) __vsc_current_command="$(builtin history 1 | sed -E 's/ *[0-9]+ +//')"

OK well done thank you

Thanks.

@rzhao271 rzhao271 added the verified Verification succeeded label Sep 14, 2022
@or4
Copy link

or4 commented Sep 15, 2022

I have v1.71.1 and nothing changed

Version: 1.71.1
Commit: e7f30e38c5a4efafeec8ad52861eb772a9ee4dfb

I have error message on each type comamnd in bash

sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]

@or4
Copy link

or4 commented Sep 15, 2022

Found solution, it helped me
https://stackoverflow.com/a/73601736/3977725

@milankrushna
Copy link

milankrushna commented Sep 15, 2022

The solution is to edit the file /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh on line 125 and use the -E flag instead of -r (since both serve the same purpose - enable use of extended regular expressions - on linux). On Mac -r is not a valid option, hence the issue.

(i.e.:) __vsc_current_command="$(builtin history 1 | sed -E 's/ *[0-9]+ +//')"

Thank a lot
it Worked!

@marcelsev
Copy link

marcelsev commented Sep 15, 2022

Thank you!!!

@FaberVitale
Copy link
Author

FaberVitale commented Sep 16, 2022

I can't reproduce it in 1.71.2 👍

Version: 1.71.2
Commit: 74b1f979648cc44d385a2286793c226e611f59e7

@mighty6ft5max
Copy link

mighty6ft5max commented Oct 3, 2022

Had it for weeks. Fixed in 1.71.2.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release terminal-shell-bash An issue in the terminal specific to bash terminal-shell-integration Shell integration, command decorations, etc. verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.