-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
57 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
|
||
# crun | ||
|
||
> Run **C** scripts, just like you would do with Python, Ruby etc. | ||
> Run **C/C++** scripts, just like you would do with Python, Ruby etc. | ||
> | ||
> [![Build Status](https://travis-ci.org/GochoMugo/crun.svg?branch=master)](https://travis-ci.org/GochoMugo/crun) | ||
|
@@ -45,10 +44,12 @@ | |
I just love C! (and why not?!) Okay! This allows me to write more C code | ||
for day-to-day tasks, not just when you want to speed up some component | ||
of an application. It makes C more practical for use. Also, it is really | ||
handy when you are learning C; everything important is contained in the | ||
handy when you are learning C/C++; everything important is contained in the | ||
single file. | ||
|
||
The first time you invoke a crun script, it is compiled using `cc` in | ||
The first time you invoke a crun script, it is compiled using | ||
`cc` (for C files with extension `.c`) or `g++` (for CPP files with | ||
extensions other than `.c`) in | ||
the directory holding the script, stored away in `/tmp/crun` and run | ||
immediately. Subsequent invocations will run the compiled executable, | ||
rather than re-compile, unless the source file has been modified | ||
|
@@ -60,7 +61,7 @@ to cache executables across restarts. If no directory exists at | |
`${CRUN_CACHE_DIR}` yet, it will be created using `mkdir -p`. Make sure | ||
`crun` has permissions to write to the directory. | ||
|
||
If you have compilation flags that you need to be passed to `cc`, you | ||
If you have compilation flags that you need to be passed to `cc`/`g++`, you | ||
place them in the **2nd line** separately, inside a comment using `/*` and | ||
`*/`. For example, | ||
|
||
|
@@ -77,10 +78,11 @@ to some weird compilation errors! | |
### extras: | ||
By default, bash expressions in the string holding the flags are **not** | ||
are evaluated. This is a neat feature **but** I do understand it adds a new edge | ||
in the attack graph. You will need to **explicitly** enable this feature, using | ||
the environment variable `${CRUN_DO_EVAL}` or the command-line argument | ||
`--do-eval`. If enabled, a string such as `/* $(pkg-config --libs libuv) */` | ||
are evaluated. This is a neat feature **but** I do understand it adds a | ||
new edge in the attack graph. You will need to **explicitly** enable | ||
this feature, using the environment variable `${CRUN_DO_EVAL}` or | ||
the command-line argument `--do-eval`. | ||
If enabled, a string such as `/* $(pkg-config --libs libuv) */` | ||
for the compilation flags will be evaluated. So, | ||
```bash | ||
|
@@ -91,8 +93,9 @@ $ export CRUN_DO_EVAL=1 # you could place this in your ~/.bashrc (or equivalent | |
$ crun --do-eval filename.c | ||
``` | ||
**Note**: Do **not** run scripts you do **not** trust, **even if** eval is disabled! Always | ||
remember, **no** system/application can ever be 100% secure! | ||
**Note**: Do **not** run scripts you do **not** trust, **even if** | ||
eval is disabled! Always remember, **no** system/application can | ||
ever be 100% secure! | ||
To allow maximum efficiency, you can create a quick template of a script | ||
using: | ||
|
@@ -117,18 +120,17 @@ skip running the compiled executable: | |
$ crun --just-compile my_script | ||
``` | ||
|
||
Since `--just-compile` will make crun **not** run your executable, any arguments | ||
passed will be considered to be more compilation flags to use. It also | ||
echo's back the path to the compiled executable. So you could do something | ||
like: | ||
Since `--just-compile` will make crun **not** run your executable, | ||
any arguments passed will be considered to be more compilation flags to | ||
use. It also echo's back the path to the compiled executable. | ||
So you could do something like: | ||
```bash | ||
$ gdb `crun --just-compile script.c -Wall -g` | ||
$ valgrind --leak-check=yes `crun --just-compile script.c -Wall -g` arg1 arg2 | ||
``` | ||
## installation: | ||
It's simple! | ||
|
@@ -159,4 +161,3 @@ The **master** branch always remains stable. Development is done on the | |
Copyright (c) 2015-2016 GochoMugo <[email protected]> | ||
|
||
[dl]:https://raw.githubusercontent.com/GochoMugo/crun/master/crun.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env crun | ||
/* -Wall */ | ||
#include <iostream> | ||
int main() { | ||
std::cout << "compiled using g++" << std::endl; | ||
return 0; | ||
} |