Other Help Topics :: tcc scripts



I just learned that you can write shell scripts in C using the tcc C compiler included in dsl!  To compile a normal program, you would use tcc test.c to compile the following file

Code Sample

/* test.c */
#include <tcclib.h>

int main()
{
    printf("Hello, DSL\n");
    return 0;
}


To run it as a shell script, create the following as a file, save it as test, change it's mode with chmod 777 test, then run it by typing test.

Code Sample

#!/usr/bin/tcc -run
#include <tcclib.h>

int main()
{
    printf("Hello, DSL\n");
    return 0;
}


I see that they have an article on SlashDot about tcc and tccboot, which compiles the kernel at boot time!  Looks like tcc is moving up in the world of being small.

I thought 777 set the directory bit.
no it can be used to set a file to read/write/execute

Brian
AwPhuch

cool. This might make it much easier to build Linux from scratch.

Might have to check it out during winter break.

-J.P.

Dafydd Cealleigh, it does set that bit.  I'm a lazy programmer, I see I could have used chmod +x test as well.

EDIT:

wrong, it doesn't set the directory bit.  I read up and then remembered (you tend to do things by route after a while instead of thinking):

1 = execute
2 = write
4 = read

add the numbers for the mode you want.  You need three numbers, one for user, the second for group, and the third for other.  So my bits were set for read, write, & execute for me, my group, and everyone.

Next Page...
original here.