Skip to content

Commit

Permalink
Added printf support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Brown committed Jun 11, 2013
1 parent 9c06e2a commit cc5790b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ concept of awk (a terse, data-driven language), and implements that with JavaScr
JavavScript every day (and if you work in the web world, you probably do), and you love awk, and you're tired
of remembering a million syntactic idiosyncracies, well, awk just might be for you.

What's Working / Not Working
----------------------------

This list represents a high-level punch-list of what functionality has been implemented, and what functionality
is left to do.

- [X] BEGIN and END rules
- [X] Regular expression rules
- [X] RS variable
- [X] Field variables ($0 - $n and NF)
- [X] NR and RS variables
- [ ] stdin input
- [ ] Multi-line functions
- [ ] Expression rules (`$1='foo' { print() }`)
What's Working
--------------

This list represents a high-level punch-list of what functionality has been implemented.

- BEGIN and END rules
- Regular expression rules
- RS variable
- Field variables ($0 - $n and NF)
- NR and RS variables
- printf support

What's Not Working
------------------

- stdin input
- Multi-line functions
- Expression rules (`$1='foo' { print() }`)

2 changes: 2 additions & 0 deletions jawk.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var fs = require('fs'),
vm = require('vm'),
printf = require('printf'),
readlines = require('./lib/readlines').readlines;

var opts = require('nomnom')
Expand Down Expand Up @@ -53,6 +54,7 @@ var jawkContext = vm.createContext({
RS: '\\s+',
NR: 0,
print: function(s) { console.log( s===undefined ? jawkContext.$0 : s ); },
printf: function() { console.log( printf.apply( this, arguments ) ); },
length: function(x) { return x===undefined ? jawkContext.$0.length : x.length; }
});

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"contributors": [
"Ethan Brown <[email protected]>"
],
"version": "0.0.2beta",
"version": "0.0.3beta",
"license": "GPL",
"dependencies": {
"nomnom": "~1.6"
"nomnom": "~1.6",
"printf": "~0.1"
},
"keywords": [
"awk",
Expand Down

0 comments on commit cc5790b

Please sign in to comment.