mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:47:35 +00:00
Userland: Port tac to LibMain
This commit is contained in:
parent
0e6576b376
commit
05f0f70b00
2 changed files with 8 additions and 11 deletions
|
@ -140,6 +140,7 @@ target_link_libraries(shot LibGUI)
|
||||||
target_link_libraries(sql LibLine LibSQL LibIPC)
|
target_link_libraries(sql LibLine LibSQL LibIPC)
|
||||||
target_link_libraries(stat LibMain)
|
target_link_libraries(stat LibMain)
|
||||||
target_link_libraries(strace LibMain)
|
target_link_libraries(strace LibMain)
|
||||||
|
target_link_libraries(tac LibMain)
|
||||||
target_link_libraries(su LibCrypt LibMain)
|
target_link_libraries(su LibCrypt LibMain)
|
||||||
target_link_libraries(tar LibArchive LibCompress)
|
target_link_libraries(tar LibArchive LibCompress)
|
||||||
target_link_libraries(telws LibProtocol LibLine)
|
target_link_libraries(telws LibProtocol LibLine)
|
||||||
|
|
|
@ -1,27 +1,26 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, Federico Guerinoni <guerinoni.federico@gmail.com>
|
* Copyright (c) 2021-2022, Federico Guerinoni <guerinoni.federico@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio rpath", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio rpath"));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector<StringView> paths;
|
Vector<StringView> paths;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.set_general_help("Concatenate files or pipes to stdout, last line first.");
|
args_parser.set_general_help("Concatenate files or pipes to stdout, last line first.");
|
||||||
args_parser.add_positional_argument(paths, "File path(s)", "path", Core::ArgsParser::Required::No);
|
args_parser.add_positional_argument(paths, "File path(s)", "path", Core::ArgsParser::Required::No);
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
Vector<FILE*> streams;
|
Vector<FILE*> streams;
|
||||||
auto num_paths = paths.size();
|
auto num_paths = paths.size();
|
||||||
|
@ -54,10 +53,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pledge("stdio", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio"));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto* stream : streams) {
|
for (auto* stream : streams) {
|
||||||
Vector<String> lines;
|
Vector<String> lines;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue