Author Topic: Can Winbatch command-stack?  (Read 164 times)

wesselr

  • Newbie
  • *
  • Posts: 1
Can Winbatch command-stack?
« on: March 10, 2020, 05:41:55 pm »
Can Winbatch stack multiple commands into a single line?

Instead of:
command1
command2

Can I do?:
command1; command2


snowsnowsnow

  • Sr. Member
  • ****
  • Posts: 313
Re: Can Winbatch command-stack?
« Reply #1 on: March 11, 2020, 02:35:18 am »
No.

JTaylor

  • Pundit
  • *****
  • Posts: 1362
    • Data & Stuff Inc.
Re: Can Winbatch command-stack?
« Reply #2 on: March 11, 2020, 05:48:51 am »
What are you trying to accomplish?   Perhaps someone will have a suggestion that helps accomplish the perceived benefit.

Jim

ChuckC

  • Full Member
  • ***
  • Posts: 247
Re: Can Winbatch command-stack?
« Reply #3 on: March 11, 2020, 11:03:14 am »
A few historical notes regarding WinBatch that might be appropriate to consider:

The semicolon character is interpreted as the start of a comment that continues for the remainder of the line that the current statement is on.  As I saw it explained by Marty Williams way back in the day, as it were, that choice was made as an accommodation of the C programming language, which most developers & script-coders were more likely to have been fluent with at the time that WinBatch was originally developed.  Given that early WinBatch shared some similar syntax and function names in common with C, the typing of a spurious semicolon at the end of the line by force of habit resulted in a harmless comment being created rather than a syntax error.

As a result of this, the usage of a semicolon for any kind of command-chaining is a syntactical "no go".

WinBatch is a scripting language, but is not a command shell.  The type of functionality that the OP was asking about is typically a "syntactic sugar" feature of a command shell's "language", as is "command pipelining".  Again, WinBatch does not support any concept of a command pipeline.

I'm guessing here based on 25+ years of using WinBatch, but with the original impetus for WinBatch being to create the happy medium of something more robust than .BAT files being processed under COMMAND.COM combined with low-level system programming access to the operating system without the need for learning C and having a C compiler, and having it work in a Windows GUI focused manner [e.g. the "Win" in "WinBatch"], having command chaining and command pipelining simply was not a design consideration.

That's just my $0.03 [$0.02 adjusted for inflation].

td

  • Tech Support
  • *****
  • Posts: 3455
    • WinBatch
Re: Can Winbatch command-stack? (OT)
« Reply #4 on: March 11, 2020, 01:24:24 pm »
Funny you should mention command shells.  WinBatch has had its own CLI since version 2019B.  What it does not have is command pipelining ability via stdin and stdout. Nor has the compiler been modified to produce Windows console executables.  These things are being considered, however.  It all depends on interest.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade