Toy project imitating busybox
Simply run: zig build
.
This will compile and install the binary to zig-out
by default (can change using -p
).
You can use it the same way as you would use busybox.
Either by calling zigbox directly
, for example:
$ zigbox hi
Hi !
Or by using a symbolic link, for example:
$ ln -s $(where zigbox) ./hi
$ ./hi
Hi !
The 'hi' applet is not (yet?) implemented.
Without arguments, it will show the available commands:
$ zigbox
zigbox :)
Currently defined applets:
- cat
- sha256sum
You can try zigbox
in a chroot environment using the chroot_test.sh
script.
The script will create a test directory and do all the needed symlink and then will try to do a chroot (may requires more privileges).
You need to build the project first with
zig build
To implement a command, simply add a <command>.zig
in src/commands
.
The entry point should have this signature:
fn (args: [][]const u8) u8;
- args being the command line arguments (containing the command name at
args[0]
)
For example:
// src/commands/hi.zig
const std = @import("std");
pub fn entry(args: [][]const u8) u8 {
std.debug.print("Hi !\n", .{});
return 0;
}