ZTree.com  | ZEN  | About...  

 Index   Back

dubugging CMD scripts   [OT]

By: Ben Kent       
Date: Jan 12,2023 at 23:22
In Response to: Set quoting (Slobodan Vujnovic)

> only way to debug them was ECHO OFF/ON!

Showing my age
With MS DOS 6.x, you could press F8 during start-up, and single step through config.sys and autoexec.bat. So if you wanted to debug a .bat script, you call it from autoexec.bat and reboot and single step.

I have long missed that feature, and have hoped in vain for MS to implement debugging of cmd scripts. These OS2 clone people have the right idea see http://www.osfree.org/docs/cmdref/cmdref.2.0143.php

As it's been ~20 years, I presume MS are not going to implement debugging support for cmd.exe, and from what I understand MS have put cmd.exe on the deprecated list, so even things that are accepted as bugs will not be fixed.
The future for MS is PowerShell, so go with the flow, I have been gradually switching to PowerShell which is far more constant and capable than cmd. Even to the point of possibly being better (I know an inflammatory comment) at least on the constancy point than *nix shells.

In my view cmd should only be used for simple, no special characters, high level, with no error trapping requirement scripts. and use something else for other uses, PS, C#, ...

PS does has some issues see https://github.com/nightroman/PowerShellTraps, and I have a few extra's, but because of it's constancy and flexible object based processing, even with those its much easier to code against than cmd, and because you can easily call the .Net level generally you can relatively easily work round issues.

PS does support debugging.

A ZEP if anyone is like minded
For the F9 Application menu
Have some new directives to
output the script as .PS1
execute under powershell.exe or pwsh.exe
encode the file as ANSI or UTF-8

I have some directives/options that could be considered
OutputFileEncodoing ANSI,UTF-8,UNICODE
ExecuteWith cmd,powershell,pwsh,zlist,zmacro



Messages in this Thread

96,194 Postings in 12,153 Threads, 350 registered users, 29 users online (1 registered, 28 guests)
Index | Admin contact |   Forum Time: Jan 27, 2023 - 12:32 am UTC  |  Hits:53,203,231  (464 Today )
RSS Feed