Skip to content

Commit

Permalink
|\ merge from release-0.3, released as 0.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
StyXman committed Oct 3, 2013
2 parents c83f9ae + 18d2236 commit e925e5c
Show file tree
Hide file tree
Showing 7 changed files with 732 additions and 269 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
ayrton (0.3) unstable; urgency=low

* Piping and basic redirection works.

-- Marcos Dione <[email protected]> Thu, 03 Oct 2013 20:42:12 +0200

ayrton (0.2) unstable; urgency=low

* New function `options()` is similar to `bash`'s `set` command. So far
Expand Down
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ So, in short:
To generate the docs:
# make docs

# First steps
# First steps: execution, output

`ayrton` syntax is Python3's with some things changed. Here's the unavoidable
'Hello world' example:
Expand Down Expand Up @@ -83,22 +83,41 @@ While we're discussing output, check out this:

Just guess were the output went :) ... (ok, ok, it went to `/dev/null`).

# Composing

Just like `sh`, you can nest callables, but you must explicitly tell it that you
want to capture the output so the nesting callable gets its input:

root= grep (cat ('/etc/shadow', _out=Capture), 'root', _out=Capture)
root= grep (cat ('/etc/passwd', _out=Capture), 'root', _out=Capture)

This seems more cumbersome than `sh`, but if you think that in any shell language
you do something similar (either using `$()`, `|` or even redirection), it's not
a high price to pay.

Another improvement over `sh` is that you can use commands as conditions:

if grep (cat ('/etc/shadow', _out=Capture), 'mdione', _out=None):
if grep (cat ('/etc/passwd', _out=Capture), 'mdione', _out=None):
print ('user «mdione» is present on your system; that's a security vulnerability right there!')

As a consequence, you can also use `and`, `or` and `not`.

# Piping, redirection

Of course, no shell scripting language can call itself so without piping, so
we had to implement it:

if cat ('/etc/passwd') | grep ('mdione', _out=None):
print ('I'm here, baby!')

Notice that this time you don't have to be explicit about the `cat`'s output;
we know it's going to a pipe, so we automatically `Capture` it. Of course, we
also have redirection:

grep ('mdione') < '/etc/passwd' > '/tmp/foo'
grep ('root') < '/etc/passwd' >> '/tmp/foo'

# Shell compatibility

Do I have you attention? Let's go for your interest. Something also useful is a
behavior similar to `pushd`/`popd`:

Expand Down Expand Up @@ -144,6 +163,8 @@ can hold any Python object, but won't be exported. The `export()` function
gives the same behavior as `bash`'s `export` command, with the caveat that values
will be automatically converted to `str`.

# Remote execution

The cherry on top of the cake, or more like the melon of top of the cupcake, is
(semi) transparent remote execution. This is achieved with the following construct:

Expand Down
14 changes: 1 addition & 13 deletions TODO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ attack it offline (when I code best).
Really do:
----------

* source
* shift
* better error reporting, including remotes
* better sh() interface (streams? yuk!)
* we're weeding out imports, we could gather a list and reimport them in the
Expand All @@ -15,12 +13,6 @@ Really do:

* if we can implement |, then no function nesting
* | is implementable, implement __ror__() for RunningCommandWrapper

* it doesn't work, __ror__() is not called and in any case it's
already too late, cat and grep have benn already called when
__or__ is called (with two RunningCommandWrapper instances)

* becareful with if cat () | grep (); error codes must be carried too

* process substitution
Expand All @@ -31,13 +23,12 @@ Really do:

* see pdb's source

* referencing non-existant envvars (FOO) is replaced by a Runner.
* becareful with buitins, might eclipse valid usages: bash() (exp) blocks /bin/bash

* add option _exec=Ture for actually executing the binary.

* check ``bash``'s manpage and see what's missing.
* subprocess + redirection (...) > foo.txt
* subprocess

* with ayrton (): ...

Expand All @@ -48,7 +39,4 @@ If we {have time,are bored}:
----------------------------

* what to do about relative/absolute command paths?
* better error reporting
* | (pipe)
* redirections, if we ever implement |
* executable path caching à la bash.
Loading

0 comments on commit e925e5c

Please sign in to comment.