Welcome, Guest. Please login or register.

Author Topic: Compiler for AmigaDOS scripts?  (Read 4100 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Compiler for AmigaDOS scripts?
« on: August 18, 2004, 01:09:12 PM »
AmigaDOS scripts always execute commands (either resident or external).

Shell reads the script file line by line, and executes lines linear.  The only change of flow happens by IF and SKIP commands, IF skips to matching ENDIF if condition is false, and SKIP either skips forward or backwards.

Generating binary from the script doesn't make any sense.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Compiler for AmigaDOS scripts?
« Reply #1 on: August 18, 2004, 03:32:14 PM »
@AMIGA-FAN
Quote
Sorry but in my opinion it does make sense: even normal programs do contain if condition and conditional branches for instance and DO GET compiled.

Yeah, but AmigaDOS scripts are no way normal programs. Shell has no DO GET or other direct loops anyway, you need to use LAB, IF and SKIP BACK.

Quote
The purpose of compiling shell scripts is to make them quick at running

Minimal time is spent on flow control. 99% of CPU time is spent on actually executing the commands.

Also, if you want 'execute' command to work the script MUST be executed from a script file as usual.

To get this thing going without a script file you'd need to implement 100% shell emulator, with emulated resident commands (if, else, endif, skip, lab, echo etc etc) and execute. And it would still be only marginally faster, as most of the time is actually spent on the external commands. It's not worth it.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Compiler for AmigaDOS scripts?
« Reply #2 on: August 18, 2004, 05:57:17 PM »
@AMIGA-FAN
Quote
Legality?

You can't redistribute AmigaOS parts, such as C commands ("unless he actually intends to include the DOS commands he uses into the exe that is. However, I would be doubtful of the legality of that."). You couldn't for example upload such compiled binaries to Aminet.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Compiler for AmigaDOS scripts?
« Reply #3 on: August 18, 2004, 09:00:42 PM »
@Karlos
Quote
As Thomas suggests, you could simply have the script as a string constant within a C program and execute it. If you want to ensure nobody can reverse engineer (by viewing a hex dump of your exe and seeing the string inside), you could encrypt your scripts with a small program and then use the encrypted data in your executable. It would decrypt the text back to a normal string and then execute it.

And this could be broken with simple SetFunction to _LVOExecute, or even SnoopDos.

Or by just simple "set echo on", if you're afraid of patching. :-)