kevinlawler / kona

Open-source implementation of the K programming language
ISC License
1.36k stars 138 forks source link

Script processing #507

Closed tavmem closed 6 years ago

tavmem commented 6 years ago

Kona will process any file as a script. k2.8 verifies that the file has a suffix of ".k" or .kr" in kona:

$ pwd
/home/tom/test
$ ls
tstScrpt
$ cat tstScrpt
1+1
$ rlwrap -n ~/kona/k tstScrpt
2
K Console - Enter \ for help

in k2.8

$ rlwrap -n ~/k2.8/k tstScrpt
K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
Evaluation. Not for commercial use. 
\ for help. \\ to exit.

tstScrpt:
tstScrpt.kr: file not found
  \\

$ mv tstScrpt tstScrpt.k
$ rlwrap -n ~/k2.8/k tstScrpt
K 2.8 2000-10-10 Copyright (C) 1993-2000 Kx Systems
Evaluation. Not for commercial use. 
\ for help. \\ to exit.

2

Also, in kona, the message "K Console - Enter \ for help" should occur before the script is processed.

refi64 commented 6 years ago

As an addendum to this: it'd be awesome if there were a way to suppress the intro message when running a script. I've taken to using echo | k ..., but it screws with asking for input...

tavmem commented 6 years ago

All 3 items have been addressed:

You suppress the banner by adding the "-b" with any value. Examples: if a script "test.k" exists, you can run it with no banner by doing any of these:

  ./k test -b 0
  ./k test.k -b 0
  ./k test -b 12345