Skip to content

Commit

Permalink
Use history in bash shell integration for unresolved aliases
Browse files Browse the repository at this point in the history
Fixes #156385
  • Loading branch information
Tyriar committed Aug 22, 2022
1 parent 9b507bc commit e55863c
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ if [[ "$(uname -s)" =~ ^CYGWIN*|MINGW*|MSYS* ]]; then
builtin printf "\x1b]633;P;IsWindows=True\x07"
fi

# Allow verifying $BASH_COMMAND doesn't have aliases resolved via history when the right HISTCONTROL
# configuration is used
if [[ "$HISTCONTROL" =~ .*(erasedups|ignoreboth|ignoredups).* ]]; then
__vsc_history_verify=0
else
__vsc_history_verify=1
fi

__vsc_initialized=0
__vsc_original_PS1="$PS1"
__vsc_original_PS2="$PS2"
Expand Down Expand Up @@ -111,7 +119,13 @@ __vsc_precmd() {
__vsc_preexec() {
__vsc_initialized=1
if [[ ! "$BASH_COMMAND" =~ ^__vsc_prompt* ]]; then
__vsc_current_command=$BASH_COMMAND
# Use history if it's available to verify the command as BASH_COMMAND comes in with aliases
# resolved
if [ "$__vsc_history_verify" = "1" ]; then
__vsc_current_command="$(builtin history 1 | sed -r 's/ *[0-9]+ +//')"
else
__vsc_current_command=$BASH_COMMAND
fi
else
__vsc_current_command=""
fi
Expand Down

15 comments on commit e55863c

@stessaris
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sed -r doesn't work on OSX Catalina, I get an error at each command in the integrated terminal

@Gr0t3Man
Copy link

@Gr0t3Man Gr0t3Man commented on e55863c Sep 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the Vscode upgrade (to 1.71.0) on my MacOs, i also get the annoying "[error message](sed: illegal option -- r)" on every command i type.
Can some please fix this please.

@stevenmilstein
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this can provide some insight https://stackoverflow.com/a/73582085/15007434

@spormeon
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also get this after last update:npm update
sed: illegal option -- r
usage: sed script [-Ealn] [-i extension] [file ...]
sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]

@Tyriar
Copy link
Member Author

@Tyriar Tyriar commented on e55863c Sep 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reports, created #159946 for the recovery release

@qaninjauk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyone have a answer i too have the same problem

@abuabdirohman4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waw, it appears in many people, I think it's just me,
Hope it's can be fixed soon.

@XtremeHammond
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mac High Sierra 10.13.6 - same issue.

@rfeliu
Copy link

@rfeliu rfeliu commented on e55863c Sep 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running Mojave 10.14.16, same issue

@UnrealJake
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running High Sierra 10.13.6 show same issue;
vscode terminal output:

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

@agemarks
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick hack:
modify /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh line 125
change sed -r to sed -E

@qaninjauk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick hack: modify /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh line 125 change sed -r to sed -E

Where can I fond this on a mac?

@spormeon
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason its gone away for me, we have power cuts the other day and after the machine had turned its self off and I rebooted, it was gone, weird.

@SuperSandrine
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick hack: modify /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh line 125 change sed -r to sed -E

Where can I fond this on a mac?

You right click on the 'visual studio Code' application, and you have choice between open or show content, choose 'show content' and then i have to follow the path provided earlier.

@Tyriar
Copy link
Member Author

@Tyriar Tyriar commented on e55863c Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this issue is tracked in #159864

Please sign in to comment.