summaryrefslogtreecommitdiff
path: root/Source/Library/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Library/Userland')
-rw-r--r--Source/Library/Userland/App/ShellApp.proto.cpp5
-rw-r--r--Source/Library/Userland/App/StreamApp.proto.cpp5
-rw-r--r--Source/Library/Userland/Binding/VirtualTerminal.class.h1
3 files changed, 7 insertions, 4 deletions
diff --git a/Source/Library/Userland/App/ShellApp.proto.cpp b/Source/Library/Userland/App/ShellApp.proto.cpp
index 840e985..123eb73 100644
--- a/Source/Library/Userland/App/ShellApp.proto.cpp
+++ b/Source/Library/Userland/App/ShellApp.proto.cpp
@@ -16,7 +16,8 @@ ShellApp::~ShellApp() {
void ShellApp::init() {
//Parse flags
u32int argc = pr.argc();
- for (u32int i = 0; i < argc; i++) {
+ args.clear();
+ for (u32int i = 1; i < argc; i++) {
String arg = pr.argv(i);
if (arg.empty()) continue;
if (arg == "-") {
@@ -89,7 +90,7 @@ void ShellApp::init() {
//Eventually show help screen
if (bFlag("help")) {
outvt << appName << ": " << appDesc << "\n";
- outvt << "Usage: \t" << appName << " <flags> [-] <arguments>\n\n";
+ outvt << "Usage: \t" << pr.argv(0) << " <flags> [-] <arguments>\n\n";
outvt << "Possible flags :\n";
for (u32int i = 0; i < flags.size(); i++) {
outvt << " --" << flags[i].lName << "\t" << (flags[i].sName != 0 ? "-" : "") << String(flags[i].sName) << "\t";
diff --git a/Source/Library/Userland/App/StreamApp.proto.cpp b/Source/Library/Userland/App/StreamApp.proto.cpp
index 97f473e..b1dc7dd 100644
--- a/Source/Library/Userland/App/StreamApp.proto.cpp
+++ b/Source/Library/Userland/App/StreamApp.proto.cpp
@@ -6,6 +6,7 @@ StreamApp::StreamApp(const String& name, const String& desc)
: ShellApp(name, desc) {
addFlag("o", "output", "Set the output to a file instead of the text output", FT_STR, "");
addFlag("e", "encoding", "Set the encoding for files (input and output)", FT_STR, "utf8");
+ addFlag("a", "append", "When writing to a file, append instead of truncating", FT_BOOL, "");
}
StreamApp::~StreamApp() {
@@ -13,7 +14,7 @@ StreamApp::~StreamApp() {
void StreamApp::init() {
ShellApp::init();
-
+
u8int encoding = UE_UTF8;
if (sFlag("encoding") == "utf8") encoding = UE_UTF8;
if (sFlag("encoding") == "utf16be") encoding = UE_UTF16_BE;
@@ -24,7 +25,7 @@ void StreamApp::init() {
if (sFlag("output") == "") {
out = &outvt;
} else {
- out = new FileOStream(sFlag("output"), FM_TRUNCATE, encoding, FS::cwdNode());
+ out = new FileOStream(sFlag("output"), (bFlag("append") ? FM_APPEND : FM_TRUNCATE), encoding, FS::cwdNode());
}
if (args.size() == 0) {
diff --git a/Source/Library/Userland/Binding/VirtualTerminal.class.h b/Source/Library/Userland/Binding/VirtualTerminal.class.h
index 54bdc53..2a38abd 100644
--- a/Source/Library/Userland/Binding/VirtualTerminal.class.h
+++ b/Source/Library/Userland/Binding/VirtualTerminal.class.h
@@ -39,6 +39,7 @@ class VirtualTerminal : public RessourceCaller, public OStream, public IStream {
String ret = String::unserialize(doCall(VTIF_READLINE, 1));
if (ret[ret.size() - 1] == WChar(EOF)) {
ret = ret.substr(0, ret.size() - 1);
+ if (ret.empty()) return "";
m_eof = true;
}
return ret += "\n";