mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
3d2d04b25e
This lets our system() and popen() commands function sort of like BusyBox and ToyBox. By default the Cosmopolitan Shell is lightweight. But if you use STATIC_YOINK then you can pull the individual commands you want into the linkage, and they'll be included in a single binary. For example the demo binary embeds `tr` and `sed` and ends up ~140kb.
26 lines
1.1 KiB
C
26 lines
1.1 KiB
C
#if 0
|
|
/*─────────────────────────────────────────────────────────────────╗
|
|
│ To the extent possible under law, Justine Tunney has waived │
|
|
│ all copyright and related or neighboring rights to this file, │
|
|
│ as it is written in the following disclaimers: │
|
|
│ • http://unlicense.org/ │
|
|
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
|
╚─────────────────────────────────────────────────────────────────*/
|
|
#endif
|
|
#include "libc/runtime/runtime.h"
|
|
#include "libc/stdio/stdio.h"
|
|
|
|
/**
|
|
* @fileoverview Cosmopolitan Command Interpreter Demo
|
|
* Yes this works on Windows.
|
|
*/
|
|
|
|
STATIC_YOINK("_tr");
|
|
STATIC_YOINK("_sed");
|
|
|
|
int main(int argc, char *argv[]) {
|
|
system("x=world\n"
|
|
"echo hello $x |\n"
|
|
" tr a-z A-Z |\n"
|
|
" sed 's/\\(.\\)/\\1 /g'");
|
|
}
|