vscode: [MacOs][Bug][Terminal] `sed: illegal option -- r` before executing commands

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 https://github.com/microsoft/vscode/commit/e55863c5c1fc4515bd99e9cd4fb415788000a8b1#diff-3d4a2862d6125445f81871e00c3b6d60fa24ef567bdf20c2a185f151a1f86129R125

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 32
  • Comments: 32 (3 by maintainers)

Commits related to this issue

Most upvoted comments

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]+ +//')"

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

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

The problem is indeed the sed -r in https://github.com/microsoft/vscode/blob/784b0177c56c607789f9638da7b6bf3230d47a8c/src/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh#L125

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 *).

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 ...]

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.

I canโ€™t reproduce it in 1.71.2 ๐Ÿ‘

Version: 1.71.2
Commit: 74b1f979648cc44d385a2286793c226e611f59e7

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