ctypes.sh

A foreign function interface for bash.

Github星跟踪图

ctypes.sh

This is ctypes.sh, a foreign function interface for bash.

ctypes.sh is a bash plugin that provides a foreign function interface directly
in your shell. In other words, it allows you to call routines in shared
libraries from within bash.

A (very) simple example will help illustrate:

$ dlcall puts "hello, world"
hello, world

# A more complex example, use libm to calculate sin(PI/2)
$ dlopen libm.so.6
0x172ebf0
$ dlcall -r double sin double:1.57079632679489661923
double:1.000000

ctypes.sh can extend bash scripts to accomplish tasks that were previously
impossible, or would require external helpers to be written.

ctypes.sh makes it possible to use
GTK+ natively in
your shell scripts, or write a high-performance http daemon.

See more examples here

prerequisites

ctypes.sh is dependent on the following libraries and programs:

  • libffi
  • bash
  • libelf (optional)
  • elfutils (optional)
  • libdwarf / libdw (optional)

install

ctypes.sh can be installed from source like this:

$ git clone https://github.com/taviso/ctypes.sh.git
$ cd ctypes.sh
$ ./autogen.sh
$ ./configure
$ make
$ [sudo] make install

By default ctypes.sh is installed into /usr/local/bin and
/usr/local/lib. You can overload the prefix path by defining the
PREFIX environment variable before installing.

$ PREFIX=$HOME make install

example

source ctypes.sh
puts () {
  dlcall puts "$@"
  return $?
}

puts "hello, world"

Here is what people have been saying about ctypes.sh:

  • "that's disgusting"
  • "this has got to stop"
  • "you've gone too far with this"
  • "is this a joke?"
  • "I never knew the c could stand for Cthulhu."

You can read more about ctypes.sh and see it in action on the Wiki

主要指标

概览
名称与所有者taviso/ctypes.sh
主编程语言C
编程语言C (语言数: 4)
平台
许可证MIT License
所有者活动
创建于2015-07-27 13:24:56
推送于2024-06-27 01:55:46
最后一次提交2024-06-27 01:55:46
发布数3
最新版本名称v1.2 (发布于 )
第一版名称v0.01 (发布于 )
用户参与
星数2.1k
关注者数53
派生数94
提交数159
已启用问题?
问题数53
打开的问题数21
拉请求数7
打开的拉请求数0
关闭的拉请求数3
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?