8000 Prevent (most) output of >= in Windows by stefanrueger · Pull Request #1992 · avrdudes/avrdude · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Prevent (most) output of >= in Windows #1992

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

Merged
merged 5 commits into from
May 21, 2025
Merged

Conversation

stefanrueger
Copy link
Collaborator

Fixes #1991

@stefanrueger stefanrueger added the misc Minor fixes like typo, overzealous compiler warning fixes, coding style changes, etc label May 19, 2025
@mcuee
Copy link
Collaborator
mcuee commented May 20, 2025

Somehow the issue is still there.

Windows CMD command prompt (same for Powershell)
Screenshot 2025-05-20 102833

src/term.c Outdated
@@ -1733,12 +1735,12 @@ static int cmd_config(const PROGRAMMER *pgm, const AVRPART *p, int argc, const c
"to show that of <property>. Wildcards or initial strings are permitted (but\n"
"not both), in which case all settings of matching properties are displayed.\n"
"\n"
"avrdude> config <property>=\n"
"avrdude> config <property>" SPBS "=\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would have preferred a space around the equation sign
avrdude> config <property> = …\n

Copy link
Collaborator

Choose a reason for hiding this comment

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

That is my preference as well, but @stefanrueger seems to say it does not work.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would have preferred it in the syntax as well. ;-)

Of course, I think it is stupid of any shell to (mis)interpret the characters that have been printed by an application in their own way, but that's a different story.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would have preferred it in the syntax as well. ;-)

🤣 That's a whole different kettle of fish. Changing the syntax of AVRDUDE in order to modify the help text is like the tail wagging the dog, but, really, changing the syntax makes the parsing a bit involved. I'd rather get to the bottom of this.

shell to (mis)interpret the characters

I suspect, but don't know, it's the display or window manager and not actually the shell.

@mcuee How does the output look when you compile and run the following C program?

#include <stdio.h>

int main() {
  printf(" -xsleep=<n> where <n>=1...666 is the sleep duration in ms\n");
}

(Bracing myself to see 666 being replaced with a devil emoji ...) Do you get the original ASCII when you cut the output from the window and paste it into the comment box here? Does any of this change when you set the locale to C as in, eg,

$ LC_ALL=C a.out

Is there an option for your shell or window manager for ASCII rather than UTF-8? An option for fixed-width teletype fonts? I mean, there must be a way for above simple program to print ASCII, not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

... and what else get's replaced in your environment? <=? !=? <>? ><? ...? 2^3? ... There must be documentation for that kind of stuff, not?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you get the original ASCII when you cut the output from the window and paste it into the comment box here?

Yes, that is the intersting part. Looks like it has more to do with the display and not related to the Windows Powershell or CMD command processor here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Under PowerShell of the problematic Windows 11 23H2 laptop.

Screenshot -- not okay.
Screenshot 2025-05-21 104614

Copy/paste the output -- Okay

C:\work\avr\avrdude_test> cat .\test_geq.c
#include <stdio.h>

int main() {
  printf(" -xsleep=<n> where <n>=1...666 is the sleep duration in ms\n");
}

C:\work\avr\avrdude_test> .\test_geq.exe
 -xsleep=<n> where <n>=1...666 is the sleep duration in ms
C:\work\avr\avrdude_test>

Copy link
Collaborator
@mcuee mcuee May 21, 2025

Choose a reason for hiding this comment

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

System Locale is already US English.
https://learn.microsoft.com/en-us/powershell/module/international/get-winsystemlocale?view=windowsserver2025-ps

C:\work\avr\avrdude_test> Get-WinSystemLocale

LCID             Name             DisplayName
----             ----             -----------
1033             en-US            English (United States)

Copy link
Collaborator
@mcuee mcuee May 21, 2025

Choose a reason for hiding this comment

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

Test C code.

#include <stdio.h>

int main() {
  printf(" <n> where n >=1 \n");
  printf(" <n> where n <=1 \n");
  printf(" <n> where n !=1 \n");
  printf(" <n> where n <>1 \n");
  printf(" <n> where n ><1 \n");
  printf(" <n> where n =1...3 \n");
  printf(" <n> where n =2^3 \n");
}

Powershell display of the above code and execution result -- not okay

Screenshot 2025-05-21 112501

Copy-paste seems to be okay.

C:\work\avr\avrdude_test> cat .\test_display.c
#include <stdio.h>

int main() {
  printf(" <n> where n >=1 \n");
  printf(" <n> where n <=1 \n");
  printf(" <n> where n !=1 \n");
  printf(" <n> where n <>1 \n");
  printf(" <n> where n ><1 \n");
  printf(" <n> where n =1...3 \n");
  printf(" <n> where n =2^3 \n");
}
C:\work\avr\avrdude_test> .\test_display.exe
 <n> where n >=1
 <n> where n <=1
 <n> where n !=1
 <n> where n <>1
 <n> where n ><1
 <n> where n =1...3
 <n> where n =2^3

Comparison of MSYS2 output
Screenshot 2025-05-21 112523

@mcuee
Copy link
Collaborator
mcuee commented May 20, 2025

More tests under Windows 11 23H2 (upgraded from Windows 10).

Got issues

  1. Windows Power Shell 1.0 (direct invocation or insider Windows Terminal)
  2. Windows Power Shell 7.5.1 on top of Windows Terminal
  3. Windows Command Prompt (CMD) (insider Windows Terminal)

Got no issues --> 3) 4) and 5) are kind of interesting.
The following results seem to say both the shell and terminal play a part.

  1. Git Bash by itself, as expected

  2. MSYS2 Bash shell (Windows Terminal or Mintty), as expected
    https://www.msys2.org/docs/terminals/

  3. Alacritty --> running on top of Windows Power Shell 1.0
    Screenshot 2025-05-20 155724

  4. Hypr --> running on top of Windows Command Prompt (CMD)
    Screenshot 2025-05-20 150434

  5. ConEmu
    Screenshot 2025-05-20 174136

@stefanrueger
Copy link
Collaborator Author

Seeing that the space-backspace sequence doesn't help, this PR has now replaced the last commit with a verbal description of the trailing =. It's a fitting nod to equality for the Windows-impaired population:

$ avrdude -qq -p m328p -c dryrun -T "config -h" 2>&1 | grep trail -A3
avrdude> config <property>=      # Note the trailing = as in config eesave=

shows all possible values that <property> can take on with the currently
set one being the only that is not commented out. Assignments

@mcuee
Copy link
Collaborator
mcuee commented May 20, 2025

More tests under Windows 11 23H2 (upgraded from Windows 10).

Got issues

  1. Windows Power Shell 1.0 (direct invocation or insider Windows Terminal)
  2. Windows Power Shell 7.5.1 on top of Windows Terminal
  3. Windows Command Prompt (CMD) (insider Windows Terminal)

Got no issues --> 3) 4) and 5) are kind of interesting. The following results seem to say both the shell and terminal play a part.

  1. Git Bash, as expcted
  2. MSYS2 Bash shell (Windows Terminal or Mintty), as expected
    https://www.msys2.org/docs/terminals/
  3. Alacritty --> running on top of Windows Power Shell 1.0
  4. Hypr --> running on top of Windows Command Prompt (CMD)
  5. ConEmu

@stefanrueger

From the above, it seems to say the issue is more with the display and not with the shell (Powershell or CMD).

More over, I cannot reproduce the issue with my laptop running Windows 11 Home 24H2 using git main. And this PR is good too.

I will check further on the laptop which has the issue (Windows 11 Enterprise 23H2).

@mcuee
Copy link
Collaborator 8000
mcuee commented May 21, 2025

@stefanrueger

This PR is good. Tested with both PowerShell and CMD under Windows 11 23H2 laptop which had the issue before.

Screenshot 2025-05-21 103756

Screenshot 2025-05-21 104132

@stefanrueger
Copy link
Collaborator Author

@mcuee Thanks! Given the many different combinations that get misrepresented, we cannot make AVRDUDE avoid all these. Will merge this PR

@mcuee
Copy link
Collaborator
mcuee commented May 21, 2025

@mcuee Thanks! Given the many different combinations that get misrepresented, we cannot make AVRDUDE avoid all these. Will merge this PR

Yes, this PR is good to go.

@stefanrueger stefanrueger merged commit d2fdfb0 into avrdudes:main May 21, 2025
15 checks passed
@stefanrueger stefanrueger deleted the geq branch May 24, 2025 08:07
@mcuee
Copy link
Collaborator
mcuee commented May 26, 2025

More tests under Windows 11 23H2 (upgraded from Windows 10).

Got issues

  1. Windows Power Shell 1.0 (direct invocation or insider Windows Terminal)
  2. Windows Power Shell 7.5.1 on top of Windows Terminal
  3. Windows Command Prompt (CMD) (insider Windows Terminal)

Got no issues --> 3) 4) and 5) are kind of interesting. The following results seem to say both the shell and terminal play a part.

  1. Git Bash by itself, as expected

  2. MSYS2 Bash shell (Windows Terminal or Mintty), as expected
    https://www.msys2.org/docs/terminals/

  3. Alacritty --> running on top of Windows Power Shell 1.0 -- Good

  4. Hypr --> running on top of Windows Command Prompt (CMD) -- Good

  5. ConEmu -- Good

Interestingly Git Bash inside Windows Terminal got the same issue as PowerShell/CMD inside Windows Terminal.

Screenshot 2025-05-26 102506

@mcuee
Copy link
Collaborator
mcuee commented May 26, 2025

Windows CMD.exe is actually okay, it is just that I choose to use Windows Terminal as the default terminal app to handle command line applications.

Screenshot 2025-05-26 103353

Once I change that to Windows Console Host, it works.
Screenshot 2025-05-26 103624

Same for PowerShell. no matter the latest version or the Windows built-in version.

Screenshot 2025-05-26 103957

Screenshot 2025-05-26 104134

@mcuee
Copy link
Collaborator
mcuee commented May 26, 2025

@stefanrueger

In the end, it is a problem with Windows Terminal for certain version of Windows. Windows Console Host is okay.

The Shell may not play a part.
https://github.com/microsoft/terminal/blob/main/doc/Niksa.md#whats-the-difference-between-a-shell-and-a-terminal

shell applications, like cmd.exe, powershell, zsh, etc. These are text-only applications that emit streams of characters. They don't care at all about how they're eventually rendered to the user. These are also sometimes referred to as "commandline client" applications.
terminal applications, like the Windows Terminal, gnome-terminal, xterm, iterm2, hyper. These are graphical applications that can be used to render the output of commandline clients.

@mcuee
Copy link
Collaborator
mcuee commented May 26, 2025

@stefanrueger
Copy link
Collaborator Author

Wiki FAQ added

Thanks! I have slightly changed the Wiki to be more specific.

I still think this is a not-our-problem issue, and I don't see a way of completely avoiding AVRDUDE output of ==, <=, >= and what else might get replaced. We don't have documentation of this Windows Terminal behaviour (eg, <property>=<value> is left unchanged without rendering >= as or ) nor do we know whether the Windows terminal has a way of switching these off globally or when running specific applications.

I will keep this issue in mind when I do code review, though.

@mcuee
Copy link
Collaborator
mcuee commented May 26, 2025

@stefanrueger

I agree it is not really an avrdude issue.

Microsoft may have already fixed the issue -- it could be that Windows Terminal is not the root cause but some other Window system component.

As mentioned, I do not have such issue in another laptop running Windows 11 Home 24H2.

Windows 23H2 is still widely used -- need to see if other users still have this issue or not on Windows 11 23H2/24H2.

Screenshot 2025-05-26 190148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
misc Minor fixes like typo, overzealous compiler warning fixes, coding style changes, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display issues under Windows
3 participants
0