summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-11 12:42:06 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-11 12:42:06 +0100
commita1e7064937afe58ecd782eff324fc145dc15ec49 (patch)
tree91b6940be5cff6789256113841b479d5b2a1eef0
parent05e772d276cd8ee3c6256003ac7f097322843716 (diff)
downloadserenity-a1e7064937afe58ecd782eff324fc145dc15ec49.zip
gron: Use pledge()
-rw-r--r--Userland/gron.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/Userland/gron.cpp b/Userland/gron.cpp
index 2f9b9c0911..76892142b3 100644
--- a/Userland/gron.cpp
+++ b/Userland/gron.cpp
@@ -44,6 +44,19 @@ static const char* color_off = "";
int main(int argc, char** argv)
{
+ if (pledge("stdio tty rpath", nullptr) < 0) {
+ perror("pledge");
+ return 1;
+ }
+
+ if (isatty(STDOUT_FILENO))
+ use_color = true;
+
+ if (pledge("stdio rpath", nullptr) < 0) {
+ perror("pledge");
+ return 1;
+ }
+
if (argc != 2) {
fprintf(stderr, "usage: gron <file>\n");
return 0;
@@ -54,12 +67,14 @@ int main(int argc, char** argv)
return 1;
}
+ if (pledge("stdio", nullptr) < 0) {
+ perror("pledge");
+ return 1;
+ }
+
auto file_contents = file->read_all();
auto json = JsonValue::from_string(file_contents);
- if (isatty(STDOUT_FILENO))
- use_color = true;
-
if (use_color) {
color_name = "\033[33;1m";
color_index = "\033[35;1m";