Re: [ Attn: Randy ] Ad-hoc Parsing?

From: T.M. Sommers (tms_at_nj.net)
Date: 12/22/04


Date: Wed, 22 Dec 2004 06:35:30 GMT

Herbert Kleebauer wrote:
> "T.M. Sommers" wrote:
>>Herbert Kleebauer wrote:
>
>>>>>@echo off
>>>>>echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>out.com
>
>>I should have thought that the reasons were obvious. The program
>>above is unreadable and unmaintainable for starters.
>
> Why is the above code more unreadable than the binary of sed?

One does not ordinarily try to read the binary of sed. If one
does want to, however, there are disassemblers. Your binary,
however, is embedded in a text file, and the inclusion of that
binary makes the text file unreadable and unmaintainable. Even
disassemblers won't help.

> For both you have the source code, the documentation and the
> binary.

Not in the batch file.

> The only difference is, that out.com is embedded
> within the script whereas sed.exe is a separate file on
> the hard disk (which means, the sript can only be executed
> when the external program is available).

Which, as has been pointed out, it always will be.

>>>That's not the problem. The problem is that you have to generate
>>>the binary header of the executable file.
>>
>>Let the assembler/compiler/linker do it for you.
>
> Then again the execution of the script depends on the
> existence of an external program (assembler/compiler/linker).

I meant on the source system, not the target system.

>>>You can also not direct
>>>include an exe file in a batch program (you have to include
>>>first a decoder program in form of a com program).
>>
>>Because the Windows shell has inadequate quoting facilities.
>
> Don't know whether you can echo any of the 256 bytes to a
> file without using an external program.

One can in Unix.

> But even if this is
> possible, it is not practical because of the size of the executables
> (at least a few kbytes compared to a few hundred bytes for
> DOS com files).

Why does that make it impractical? Note that Unix shells have
here documents, so that you would not have to break up your
binary into line-sized chunks.

>>>>>>IMO, unix shells are more powerful because of the standard
>>>>>>tools offered. Such as grep, find, with pipes so you can find every
>>>>>>file, and print them to the printer if you wanted.
>>>>>
>>>That's illogical. A shell can't be powerful because of other tools.
>>
>>But your argument is that the Windows shell is more powerful than
>>the Unix shells because Windows has COM files. You are being
>>inconsistent.
>
> I never said that the Windows shell is more powerful than a Unix
> shell. Here the original statement:
>
> > One of the biggest advantages of Unix-like shells
> > is that they allow the user to do things that the creator of the
> > shell never imagined.
>
> But they can't be more flexible than DOS/Windows batch scripts,
> where you can directly insert processor instructions into the
> script. Anything a computer can do, a DOS/Win batch script also
> can do.
>
> I said a Unix script can't be more flexible than a DOS/Windows script,

Somewhere you used the word 'powerful', but that doesn't matter.
  Change 'powerful' to 'flexible' in my previous post, and the
point remains: you are being inconsistent.

> because in a DOS batch script you can temporary escape the shell and
> directly execute processor instructions (without any external program).

First, I have shown that one can do the same in Unix, if one were
daft enough to want to. Second, your example does not have the
shell 'directly executing processor instructions (without any
external program)', it has the shell program creating an external
program and then loading and executing it via the OS (another
external program).

-- 
Thomas M. Sommers -- tms@nj.net -- AB2SB


Relevant Pages

  • Re: [ Attn: Randy ] Ad-hoc Parsing?
    ... > therefore you loose the primary advantage of writing a script and may ... > matching Unix. ... You use six external programs ('tidy', 'make-make', ... program and not by the shell, ...
    (alt.lang.asm)
  • Re: How to get the application path
    ... Why do you limit this to "Unix"? ... shell process waiting until the the binary proper returns. ... Could you tell me the equivalent of my script in CMD.exe? ... installation location in the registry and how I ...
    (comp.lang.ada)
  • Re: How to get the application path
    ... Why do you limit this to "Unix"? ... shell process waiting until the the binary proper returns. ... Could you tell me the equivalent of my script in CMD.exe? ... Application paths in Windows are supposed to be set in the registry; ...
    (comp.lang.ada)
  • comp.unix.shell FAQ - Answers to Frequently Asked Questions
    ... It spells "unix" in lower case letters ... The other level is how to write shell scripts. ... than standard unix utilities, it should be included in this FAQ. ... How do I get a script to update my current environment? ...
    (comp.unix.shell)
  • Re: [ Attn: Randy ] Ad-hoc Parsing?
    ... the binary of sed within the script, ... Many executables are compressed. ... That's maybe true for a standard Unix installation. ... only the shell program and no other external program. ...
    (alt.lang.asm)

Loading