Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?

Microsoft Windows
Post Reply
PiotrMP006
Posts: 20
Joined: 2021-Sep-01, 10:57 am

Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?

Post by PiotrMP006 »

Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?

Image

Please help
User avatar
Simon Sheppard
Posts: 196
Joined: 2021-Jul-10, 7:46 pm
Contact:

Re: Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?

Post by Simon Sheppard »

While the session is paused, the text "- pause" will be appended to the window TITLE.

The only way I can think to prevent that would be setting a TITLE with lots of spaces at the end, up to the maximum length of 243 or 259 characters long. Then the additional "- pause" text will not be displayed.
There is a non-zero chance this might create some kind of overflow condition, but it seems to work in a quick test.
jeb
Posts: 16
Joined: 2023-May-10, 1:28 pm

Re: Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?

Post by jeb »

You could use

Code: Select all

pause 2>nul | title Test
User avatar
Simon Sheppard
Posts: 196
Joined: 2021-Jul-10, 7:46 pm
Contact:

Re: Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?

Post by Simon Sheppard »

Interesting, just piping pause to title throws the error "The process tried to write to a nonexistent pipe"
but if you redirect stdout to Nul, there is no error:

Code: Select all

pause >nul | title
jeb
Posts: 16
Joined: 2023-May-10, 1:28 pm

Re: Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?

Post by jeb »

Simon Sheppard wrote: 2024-May-30, 4:56 pm Interesting, just piping pause to title throws the error "The process tried to write to a nonexistent pipe"
but if you redirect stdout to Nul, there is no error:
But it's pretty obvious that there's nothing left that could be written to the pipe if you redirect the output to nul.
User avatar
Simon Sheppard
Posts: 196
Joined: 2021-Jul-10, 7:46 pm
Contact:

Re: Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?

Post by Simon Sheppard »

Yes, so I think its better to use >nul rather than 2>nul which just hides the error, but I'm still puzzled why the error in the first place - where did the pipe go?
Perhaps it is just because Title does not accept piped input.
jeb
Posts: 16
Joined: 2023-May-10, 1:28 pm

Re: Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?

Post by jeb »

You are right, it seems better to use > NUL.
Simon Sheppard wrote: 2024-May-31, 8:12 am but I'm still puzzled why the error in the first place - where did the pipe go?
The title command ends shortly after the title is set, but the pause only generates the output when the user presses a key.
Simon_Weel
Posts: 37
Joined: 2021-Dec-13, 3:53 pm

Re: Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?

Post by Simon_Weel »

If you add something like echo, then it works fine:

Code: Select all

title Test & echo & pause
Post Reply