1
-
2
1
# crun
3
2
4
- > Run ** C** scripts, just like you would do with Python, Ruby etc.
3
+ > Run ** C/C++ ** scripts, just like you would do with Python, Ruby etc.
5
4
>
6
5
> [ ![ Build Status] ( https://travis-ci.org/GochoMugo/crun.svg?branch=master )] ( https://travis-ci.org/GochoMugo/crun )
7
6
45
44
I just love C! (and why not? ! ) Okay! This allows me to write more C code
46
45
for day-to-day tasks, not just when you want to speed up some component
47
46
of an application. It makes C more practical for use. Also, it is really
48
- handy when you are learning C; everything important is contained in the
47
+ handy when you are learning C/C++ ; everything important is contained in the
49
48
single file.
50
49
51
- The first time you invoke a crun script, it is compiled using ` cc` in
50
+ The first time you invoke a crun script, it is compiled using
51
+ ` cc` (for C files with extension ` .c` ) or ` g++` (for CPP files with
52
+ extensions other than ` .c` ) in
52
53
the directory holding the script, stored away in ` /tmp/crun` and run
53
54
immediately. Subsequent invocations will run the compiled executable,
54
55
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
60
61
` ${CRUN_CACHE_DIR} ` yet, it will be created using ` mkdir -p` . Make sure
61
62
` crun` has permissions to write to the directory.
62
63
63
- If you have compilation flags that you need to be passed to ` cc` , you
64
+ If you have compilation flags that you need to be passed to ` cc` / ` g++ ` , you
64
65
place them in the ** 2nd line** separately, inside a comment using ` /* ` and
65
66
` * /` . For example,
66
67
@@ -77,10 +78,11 @@ to some weird compilation errors!
77
78
### extras:
78
79
79
80
By default, bash expressions in the string holding the flags are **not**
80
- are evaluated. This is a neat feature **but** I do understand it adds a new edge
81
- in the attack graph. You will need to **explicitly** enable this feature, using
82
- the environment variable `${CRUN_DO_EVAL}` or the command-line argument
83
- `--do-eval`. If enabled, a string such as `/* $(pkg-config --libs libuv) */`
81
+ are evaluated. This is a neat feature **but** I do understand it adds a
82
+ new edge in the attack graph. You will need to **explicitly** enable
83
+ this feature, using the environment variable `${CRUN_DO_EVAL}` or
84
+ the command-line argument `--do-eval`.
85
+ If enabled, a string such as `/* $(pkg-config --libs libuv) */`
84
86
for the compilation flags will be evaluated. So,
85
87
86
88
```bash
@@ -91,8 +93,9 @@ $ export CRUN_DO_EVAL=1 # you could place this in your ~/.bashrc (or equivalent
91
93
$ crun --do-eval filename.c
92
94
```
93
95
94
- **Note**: Do **not** run scripts you do **not** trust, **even if** eval is disabled! Always
95
- remember, **no** system/application can ever be 100% secure!
96
+ **Note**: Do **not** run scripts you do **not** trust, **even if**
97
+ eval is disabled! Always remember, **no** system/application can
98
+ ever be 100% secure!
96
99
97
100
To allow maximum efficiency, you can create a quick template of a script
98
101
using:
@@ -117,18 +120,17 @@ skip running the compiled executable:
117
120
$ crun --just-compile my_script
118
121
` ` `
119
122
120
- Since ` --just-compile` will make crun ** not** run your executable, any arguments
121
- passed will be considered to be more compilation flags to use. It also
122
- echo' s back the path to the compiled executable. So you could do something
123
- like:
123
+ Since ` --just-compile` will make crun ** not** run your executable,
124
+ any arguments passed will be considered to be more compilation flags to
125
+ use. It also echo' s back the path to the compiled executable.
126
+ So you could do something like:
124
127
125
128
```bash
126
129
$ gdb `crun --just-compile script.c -Wall -g`
127
130
$ valgrind --leak-check=yes `crun --just-compile script.c -Wall -g` arg1 arg2
128
131
```
129
132
130
133
131
-
132
134
## installation:
133
135
134
136
It' s simple!
@@ -159,4 +161,3 @@ The **master** branch always remains stable. Development is done on the
159
161
Copyright (c) 2015-2016 GochoMugo < mugo@forfuture.co.ke>
160
162
161
163
[dl]:https://raw.githubusercontent.com/GochoMugo/crun/master/crun.sh
162
-
0 commit comments