* [gentoo-commits] proj/libbash:master commit in: scripts/, src/builtins/
@ 2011-05-27 23:03 Petteri Räty
0 siblings, 0 replies; 2+ messages in thread
From: Petteri Räty @ 2011-05-27 23:03 UTC (permalink / raw
To: gentoo-commits
commit: f2cf06bb14022d693a21b6f2763314770b912034
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Wed May 25 14:11:47 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu May 26 08:20:31 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=f2cf06bb
Builtin: fix a bug in echo built-in
The echo built-in should print an empty line if no argument is
provided. Now this is supported.
---
scripts/function_def.bash.result | 1 +
src/builtins/echo_builtin.cpp | 6 ++++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/scripts/function_def.bash.result b/scripts/function_def.bash.result
index 41e19ca..cebbfae 100644
--- a/scripts/function_def.bash.result
+++ b/scripts/function_def.bash.result
@@ -1,4 +1,5 @@
hi 1 1
+
overloaded let
1 2 3
1 2 3
diff --git a/src/builtins/echo_builtin.cpp b/src/builtins/echo_builtin.cpp
index 28b4d65..0e21707 100644
--- a/src/builtins/echo_builtin.cpp
+++ b/src/builtins/echo_builtin.cpp
@@ -42,6 +42,12 @@ int echo_builtin::exec(const std::vector<std::string>& bash_args)
bool enable_escapes = false;
bool options_parsed = false;
+ if(bash_args.empty())
+ {
+ this->out_buffer() << std::endl;
+ return 0;
+ }
+
for(auto i = bash_args.begin(); i != bash_args.end(); i++)
{
const std::string& str = *i;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/libbash:master commit in: scripts/, src/builtins/
@ 2012-06-03 9:08 Petteri Räty
0 siblings, 0 replies; 2+ messages in thread
From: Petteri Räty @ 2012-06-03 9:08 UTC (permalink / raw
To: gentoo-commits
commit: c5fb1ffc57b41faa6118e36b2ae925561915fc6a
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 26 08:08:40 2012 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Mar 26 08:35:47 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=c5fb1ffc
Builtin: fix argument handling of printf builtin
---
scripts/command_execution.bash | 3 +++
src/builtins/printf_builtin.cpp | 20 +++++++++++++++-----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/scripts/command_execution.bash b/scripts/command_execution.bash
index 615b13f..0927642 100644
--- a/scripts/command_execution.bash
+++ b/scripts/command_execution.bash
@@ -62,6 +62,9 @@ eval "echo abc" "def" "xyz"
shopt -s extglob
printf "%s %s\n" abc def
printf "%s %s\n" $FOO001, def
+printf "123-%s" 456 789
+printf "\n"
+printf "123-%s"
((FOO010=1))
echo $FOO010
echo "abc #av### ##" # for comment
diff --git a/src/builtins/printf_builtin.cpp b/src/builtins/printf_builtin.cpp
index db40fff..0d2ef1c 100644
--- a/src/builtins/printf_builtin.cpp
+++ b/src/builtins/printf_builtin.cpp
@@ -41,23 +41,33 @@ int printf_builtin::exec(const std::vector<std::string>& bash_args)
std::stringstream format_string;
cppbash_builtin::transform_escapes(*begin, format_string, false);
boost::format formatter(format_string.str());
+ formatter.exceptions(boost::io::all_error_bits ^ boost::io::too_few_args_bit);
+
+ std::stringstream output;
for(auto iter = begin + 1; iter != bash_args.end(); ++iter)
- formatter = formatter % *iter;
+ try
+ {
+ formatter = formatter % *iter;
+ }
+ catch(const boost::io::too_many_args& e)
+ {
+ output << formatter;
+ formatter.parse(format_string.str());
+ formatter = formatter % *iter;
+ }
+ output << formatter;
if(!(bash_args[0][0] == '-'))
{
- *_out_stream << formatter;
+ *_out_stream << output.str();
}
else if(bash_args[0] == "-v")
{
- std::stringstream output;
- output << formatter;
_walker.set_value(bash_args[1], output.str());
}
else
{
throw libbash::illegal_argument_exception("printf: invalid option: " + bash_args[0]);
}
-
return 0;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-03 9:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-03 9:08 [gentoo-commits] proj/libbash:master commit in: scripts/, src/builtins/ Petteri Räty
-- strict thread matches above, loose matches on Subject: below --
2011-05-27 23:03 Petteri Räty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox