_                         
 ___| |__   __ _ ___ _ __ ___  
/ __| '_ \ / _` / __| '_ ` _ \ 
\__ \ | | | (_| \__ \ | | | | |
|___/_| |_|\__,_|___/_| |_| |_|

NOTE: This exists currently as an idea

shasm transpiles your existing .sh files into C programs and then into asm.

Why?

I want to write C programs that are advanced, fast and quick.

I was thinking of writing emmet like abbrevations for C, until it suddenly hit me. Shell files almost have a 1 to 1 map with system calls much similar to C.

FILE* fp = fopen("somefile.txt"); 
fprintf(stdout, fp);

The above code can be simplified to just,

cat  somefile

How would this even work?

If you take a look at the POSIX shell. You can map almost every feature to an POSIX system calls.

> shell.txt file("shell.txt", "w")
>> shell.txt    file("shell.txt", "a")

Shell scripts consists of programs getting glued to one another using '|'. The '|' is actually a pipe() system call.

Almost all the features of shell has a direct corelation with system's api but not all.

sed 's/slow/fast/g' old.txt > new.txt

The above command utilizes a external program called sed. shasm passes the values carefully to another tool called sed-bin in the C space using some glue code of course.

The same hack will be done for awk using awka, and ofcourse for other similar specilized tools.

Some commands are really simple to map to, such as the printf command.

There will be an interface available for the users of this transpiler to specify the external commands that are non-standard. That can be arranged by describing a function based on the flags and specifying it's type(s).

#git.someexetension
add libgit.a.somenamespace_git_add()

For others commands that you cannot specify, a simple system command will be run after checking for it's availability.

system("external_command");