From 9b334d0ee0d9ddcb80ada4b085df6a7af7ccc972 Mon Sep 17 00:00:00 2001 From: Dr-Carlos Date: Sat, 16 Apr 2022 07:53:27 +0930 Subject: [PATCH 1/2] _e: throw error when vspace does not exist --- shell/e.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/shell/e.cpp b/shell/e.cpp index 6ee41ad..d7e71a9 100644 --- a/shell/e.cpp +++ b/shell/e.cpp @@ -1,6 +1,7 @@ #include "shell.h" #include "parser.h" #include "commands.h" +#include "errors.h" #include #include @@ -18,15 +19,25 @@ struct _e_args static _e_args parse_e(Session &session, Parser &parser) { _e_args args {}; + parser.option("vspace", [&args](std::string const &value) { args.space_name = value; }); - VirtualSpace *space = session.get_space(args.space_name); - if(space) { - while(!parser.at_end()) { + parser.accept_options(); + + VirtualSpace *space; + if (!args.space_name.empty()) + space = session.get_space(args.space_name); + else + space = session.current_space; + + if (space) + while(!parser.at_end()) args.values.push_back(parser.expr(space)); - } - } + else + throw CommandError("virtual space {} does not exist", + args.space_name); + // TODO: Error message when session specified in _e does not exist parser.end(); From 789fc3325cca4dfb6b256c9d7f6a4033072fb6a5 Mon Sep 17 00:00:00 2001 From: Dr-Carlos Date: Mon, 18 Apr 2022 06:53:03 +0930 Subject: [PATCH 2/2] _e: print instead of throwing error --- shell/e.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/e.cpp b/shell/e.cpp index d7e71a9..c1aea82 100644 --- a/shell/e.cpp +++ b/shell/e.cpp @@ -5,6 +5,7 @@ #include #include +#include //--- // e @@ -26,17 +27,16 @@ static _e_args parse_e(Session &session, Parser &parser) parser.accept_options(); VirtualSpace *space; - if (!args.space_name.empty()) + if(!args.space_name.empty()) space = session.get_space(args.space_name); else space = session.current_space; - if (space) + if(space) while(!parser.at_end()) args.values.push_back(parser.expr(space)); else - throw CommandError("virtual space {} does not exist", - args.space_name); + FxOS_log(ERR, "virtual space '%s' does not exist", args.space_name); // TODO: Error message when session specified in _e does not exist