mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
gron: Use pledge()
This commit is contained in:
parent
05e772d276
commit
a1e7064937
1 changed files with 18 additions and 3 deletions
|
@ -44,6 +44,19 @@ static const char* color_off = "";
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
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) {
|
if (argc != 2) {
|
||||||
fprintf(stderr, "usage: gron <file>\n");
|
fprintf(stderr, "usage: gron <file>\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -54,12 +67,14 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pledge("stdio", nullptr) < 0) {
|
||||||
|
perror("pledge");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
auto file_contents = file->read_all();
|
auto file_contents = file->read_all();
|
||||||
auto json = JsonValue::from_string(file_contents);
|
auto json = JsonValue::from_string(file_contents);
|
||||||
|
|
||||||
if (isatty(STDOUT_FILENO))
|
|
||||||
use_color = true;
|
|
||||||
|
|
||||||
if (use_color) {
|
if (use_color) {
|
||||||
color_name = "\033[33;1m";
|
color_name = "\033[33;1m";
|
||||||
color_index = "\033[35;1m";
|
color_index = "\033[35;1m";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue