From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: src/builtins/tests/, src/builtins/
Date: Sun, 3 Jun 2012 09:08:42 +0000 (UTC) [thread overview]
Message-ID: <1338028850.846f3e937c727996a114045f06f5a0c5ab660619.betelgeuse@gentoo> (raw)
commit: 846f3e937c727996a114045f06f5a0c5ab660619
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 27 11:53:09 2012 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat May 26 10:40:50 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=846f3e93
Builtin: improve error output for some builtins
---
src/builtins/declare_builtin.cpp | 8 ++++----
src/builtins/shopt_builtin.cpp | 6 +++---
src/builtins/source_builtin.cpp | 2 +-
src/builtins/tests/declare_tests.cpp | 8 ++++----
src/builtins/tests/shopt_tests.cpp | 6 +++---
5 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/builtins/declare_builtin.cpp b/src/builtins/declare_builtin.cpp
index 1c85d61..db955c4 100644
--- a/src/builtins/declare_builtin.cpp
+++ b/src/builtins/declare_builtin.cpp
@@ -32,18 +32,18 @@ int declare_builtin::exec(const std::vector<std::string>& bash_args)
{
if(bash_args.empty())
{
- throw libbash::illegal_argument_exception("Arguments required for declare");
+ throw libbash::illegal_argument_exception("declare: arguments required");
return 1;
}
else if(bash_args[0].size() != 2)
{
- throw libbash::unsupported_exception("Multiple arguments are not supported");
+ throw libbash::unsupported_exception("declare: multiple arguments are not supported");
return 1;
}
if(bash_args[0][0] != '-' && bash_args[0][0] != '+')
{
- throw libbash::illegal_argument_exception("Invalid option for declare builtin");
+ throw libbash::illegal_argument_exception("declare: invalid option");
return 1;
}
@@ -108,7 +108,7 @@ int declare_builtin::exec(const std::vector<std::string>& bash_args)
throw libbash::unsupported_exception("declare " + bash_args[0] + " is not supported yet");
return 1;
default:
- throw libbash::illegal_argument_exception("Unrecognized option for declare: " + bash_args[0]);
+ throw libbash::illegal_argument_exception("declare: unrecognized option: " + bash_args[0]);
return 1;
}
}
diff --git a/src/builtins/shopt_builtin.cpp b/src/builtins/shopt_builtin.cpp
index fd9e581..1e3da70 100644
--- a/src/builtins/shopt_builtin.cpp
+++ b/src/builtins/shopt_builtin.cpp
@@ -42,9 +42,9 @@ void shopt_builtin::print_opts() const
int shopt_builtin::exec(const std::vector<std::string>& bash_args)
{
if(bash_args.empty())
- throw libbash::illegal_argument_exception("Arguments required for shopt");
+ throw libbash::illegal_argument_exception("shopt: arguments required");
else if(bash_args[0].size() != 2)
- throw libbash::unsupported_exception("Multiple arguments are not supported");
+ throw libbash::unsupported_exception("shopt: multiple arguments are not supported");
switch(bash_args[0][1])
{
@@ -61,7 +61,7 @@ int shopt_builtin::exec(const std::vector<std::string>& bash_args)
case 'o':
throw libbash::unsupported_exception("shopt " + bash_args[0] + " is not supported yet");
default:
- throw libbash::illegal_argument_exception("Unrecognized option for shopt: " + bash_args[0]);
+ throw libbash::illegal_argument_exception("shopt: unrecognized option: " + bash_args[0]);
}
return 0;
diff --git a/src/builtins/source_builtin.cpp b/src/builtins/source_builtin.cpp
index 91f3397..7af4f91 100644
--- a/src/builtins/source_builtin.cpp
+++ b/src/builtins/source_builtin.cpp
@@ -65,7 +65,7 @@ namespace {
int source_builtin::exec(const std::vector<std::string>& bash_args)
{
if(bash_args.size() == 0)
- throw libbash::illegal_argument_exception("should provide one argument for source builtin");
+ throw libbash::illegal_argument_exception("source: argument required");
const std::string& original_path = _walker.resolve<std::string>("0");
_walker.define("0", bash_args.front(), true);
diff --git a/src/builtins/tests/declare_tests.cpp b/src/builtins/tests/declare_tests.cpp
index 686c816..19347ac 100644
--- a/src/builtins/tests/declare_tests.cpp
+++ b/src/builtins/tests/declare_tests.cpp
@@ -54,10 +54,10 @@ namespace
TEST(declare_builtin_test, invalid_arguments)
{
- test_declare<libbash::illegal_argument_exception>("Arguments required for declare", {});
- test_declare<libbash::unsupported_exception>("Multiple arguments are not supported", {"-ap"});
- test_declare<libbash::illegal_argument_exception>("Invalid option for declare builtin", {"_a"});
- test_declare<libbash::illegal_argument_exception>("Unrecognized option for declare: -L", {"-L"});
+ test_declare<libbash::illegal_argument_exception>("declare: arguments required", {});
+ test_declare<libbash::unsupported_exception>("declare: multiple arguments are not supported", {"-ap"});
+ test_declare<libbash::illegal_argument_exception>("declare: invalid option", {"_a"});
+ test_declare<libbash::illegal_argument_exception>("declare: unrecognized option: -L", {"-L"});
}
TEST(declare_builtin_test, _F)
diff --git a/src/builtins/tests/shopt_tests.cpp b/src/builtins/tests/shopt_tests.cpp
index dc43dee..af2915b 100644
--- a/src/builtins/tests/shopt_tests.cpp
+++ b/src/builtins/tests/shopt_tests.cpp
@@ -69,8 +69,8 @@ TEST(shopt_builtin_test, enable_extglob)
TEST(shopt_builtin_test, invalid_argument)
{
- test_shopt_builtin<libbash::illegal_argument_exception>("Arguments required for shopt", {});
- test_shopt_builtin<libbash::unsupported_exception>("Multiple arguments are not supported", {"-so"});
+ test_shopt_builtin<libbash::illegal_argument_exception>("shopt: arguments required", {});
+ test_shopt_builtin<libbash::unsupported_exception>("shopt: multiple arguments are not supported", {"-so"});
test_shopt_builtin<libbash::unsupported_exception>("shopt -q is not supported yet", {"-q"});
- test_shopt_builtin<libbash::illegal_argument_exception>("Unrecognized option for shopt: -d", {"-d"});
+ test_shopt_builtin<libbash::illegal_argument_exception>("shopt: unrecognized option: -d", {"-d"});
}
next reply other threads:[~2012-06-03 9:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-03 9:08 Petteri Räty [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-06-25 10:05 [gentoo-commits] proj/libbash:master commit in: src/builtins/tests/, src/builtins/ Petteri Räty
2011-06-09 7:27 Petteri Räty
2011-05-27 23:03 Petteri Räty
2011-05-25 19:42 Petteri Räty
2011-05-25 19:42 Petteri Räty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1338028850.846f3e937c727996a114045f06f5a0c5ab660619.betelgeuse@gentoo \
--to=betelgeuse@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox