Terminal Escape Sequences expected behavior?
Posted: 22 Nov 2021 07:23
I've noticed a discrepancy between the behavior of certain terminal escape sequences when another instance of cmd.exe or powershell is invoked. I'll provide a couple brief examples.
1. Let's say you want to stop the cursor from blinking:
In this instance, the cursor stops blinking and remains regardless if I invoke cmd.exe or powershell.
2. Lets say you want to change the title and Run the script as Administrator:
or
In each case here, invoking cmd.exe or powershell changes the title to include Administrator.
Is that expected behavior for a Operating System Command (OSC) sequence as opposed to a Control Sequence Introducer (CSI)?
1. Let's say you want to stop the cursor from blinking:
Code: Select all
@echo off
setlocal enabledelayedexpansion
for /f %%e in ('echo prompt $E^|cmd') do set "\e=%%e"
echo Hi
echo %\e%[?12l
powershell /command "Get-Host | Select Version"
cmd /k echo Hi
2. Lets say you want to change the title and Run the script as Administrator:
Code: Select all
@echo off
setlocal enabledelayedexpansion
for /f %%e in ('echo prompt $E^|cmd') do set "\e=%%e"
for /f %%g in ('%__APPDIR__%forfiles.exe /p "%~dp0." /m "%~nx0" /c "cmd /c echo 0x07"') do set "bel=%%g"
echo %\e%]0;Test Title%BEL%
pause
powershell /command "Get-Host | Select Version"
Code: Select all
@echo off
setlocal enabledelayedexpansion
for /f %%e in ('echo prompt $E^|cmd') do set "\e=%%e"
for /f %%g in ('%__APPDIR__%forfiles.exe /p "%~dp0." /m "%~nx0" /c "cmd /c echo 0x07"') do set "bel=%%g"
echo %\e%]0;Test Title%BEL%
pause
cmd /k echo Hi
Is that expected behavior for a Operating System Command (OSC) sequence as opposed to a Control Sequence Introducer (CSI)?