Skip to content

Commit

Permalink
Strongly link sed and tr into system() and popen()
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Nov 16, 2024
1 parent cafdb45 commit 7013106
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ include libc/BUILD.mk #─┘
include libc/sock/BUILD.mk #─┐
include net/http/BUILD.mk # ├──ONLINE RUNTIME
include third_party/musl/BUILD.mk # │ You can communicate with the network
include third_party/regex/BUILD.mk #
include third_party/tr/BUILD.mk #
include third_party/sed/BUILD.mk #
include libc/system/BUILD.mk #
include libc/x/BUILD.mk #
include dsp/scale/BUILD.mk #
Expand All @@ -294,8 +297,7 @@ include third_party/libcxx/BUILD.mk # │
include third_party/openmp/BUILD.mk #
include third_party/pcre/BUILD.mk #
include third_party/less/BUILD.mk #
include net/https/BUILD.mk #
include third_party/regex/BUILD.mk #─┘
include net/https/BUILD.mk #─┘
include third_party/tidy/BUILD.mk
include third_party/BUILD.mk
include third_party/nsync/testing/BUILD.mk
Expand All @@ -314,8 +316,6 @@ include third_party/double-conversion/test/BUILD.mk
include third_party/lua/BUILD.mk
include third_party/tree/BUILD.mk
include third_party/zstd/BUILD.mk
include third_party/tr/BUILD.mk
include third_party/sed/BUILD.mk
include third_party/awk/BUILD.mk
include third_party/hiredis/BUILD.mk
include third_party/make/BUILD.mk
Expand Down
2 changes: 2 additions & 0 deletions libc/system/BUILD.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ LIBC_SYSTEM_A_DIRECTDEPS = \
LIBC_STR \
LIBC_SYSV \
THIRD_PARTY_MUSL \
THIRD_PARTY_SED \
THIRD_PARTY_TR \

LIBC_SYSTEM_A_DEPS := \
$(call uniq,$(foreach x,$(LIBC_SYSTEM_A_DIRECTDEPS),$($(x))))
Expand Down
13 changes: 5 additions & 8 deletions libc/system/cocmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,15 +743,12 @@ static int TryBuiltin(bool wantexec) {
return Usleep();
if (!strcmp(args[0], "toupper"))
return Toupper();
if (_weaken(_tr) && !strcmp(args[0], "tr")) {
return Fake(_weaken(_tr), wantexec);
}
if (_weaken(_sed) && !strcmp(args[0], "sed")) {
return Fake(_weaken(_sed), wantexec);
}
if (_weaken(_awk) && !strcmp(args[0], "awk")) {
if (!strcmp(args[0], "tr"))
return Fake(_tr, wantexec);
if (!strcmp(args[0], "sed"))
return Fake(_sed, wantexec);
if (_weaken(_awk) && strcmp(args[0], "awk"))
return Fake(_weaken(_awk), wantexec);
}
if (_weaken(_curl) && !strcmp(args[0], "curl")) {
return Fake(_weaken(_curl), wantexec);
}
Expand Down
4 changes: 1 addition & 3 deletions libc/system/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
* provides Bourne-like syntax on all platforms, including Windows. Many
* builtin commands are included, e.g. exit, cd, rm, [, cat, wait, exec,
* env, echo, read, true, test, kill, touch, rmdir, mkdir, false, mktemp
* and usleep. It's also possible to __static_yoink() the symbols `_tr`,
* `_sed`, `_awk`, and `_curl` for the tr, sed, awk and curl commands if
* you're using the Cosmopolitan mono-repo.
* sed, tr, and usleep.
*
* If you just have a program name and arguments, and you don't need the
* full power of a UNIX-like shell, then consider using the Cosmopolitan
Expand Down

0 comments on commit 7013106

Please sign in to comment.