jeremydouglass / rosetta_examples_p5

Example set from Rosetta Code for P5 (Processing)
Other
10 stars 2 forks source link

[ADD EXAMPLE] Shell one-liner #31

Open jeremydouglass opened 4 years ago

jeremydouglass commented 4 years ago

https://rosettacode.org/wiki/Shell_one-liner#Processing

The shell one-liner sketch is actually a bash shell script designed for the processing-java command line tool, so it cannot be implemented as a PDE sketch. It could perhaps be added as a shell script in a folder, although it would not appear in the PDE Examples menu.

The command-line tool processing-java takes a sketch directory (not a file) and so a simple program cannot be piped in from the shell using process substitution. However, a long shell one-liner may write a sketch file to disk, then run it, so long as the folder name and the PDE file name match, e.g. /Tmp/Tmp.pde

In bash:

mkdir -p Tmp; echo "println(\"hello world\");" > Tmp/Tmp.pde; processing-java --sketch="`pwd`/Tmp" --run

Output:

hello world

jeremydouglass commented 4 years ago

An alternate (or additional) way to approach this would be to demonstrate how a shell one-liner is invoked from within a processing sketch, e.g. wth launch() / exec() https://processing.org/reference/launch_.html