public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, src/core/, bashast/, test/
Date: Wed, 27 Apr 2011 15:11:11 +0000 (UTC)	[thread overview]
Message-ID: <33d754abccf45c6144be7341dcccca03623ad418.betelgeuse@gentoo> (raw)

commit:     33d754abccf45c6144be7341dcccca03623ad418
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 25 10:03:39 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Apr 26 07:09:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=33d754ab

Walker: support special variables in var_ref

The syntax for special variables is now supported. Only $? has a
runtime now.

---
 bashast/libbashWalker.g     |    6 ++++++
 scripts/var_def.bash        |    6 ++++++
 scripts/var_def.bash.result |    6 ++++++
 src/core/interpreter.h      |    8 ++++++++
 test/script_compiler.sh     |    2 +-
 5 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index eec0218..11b4c19 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -268,6 +268,12 @@ var_ref [bool double_quoted] returns[std::string libbash_value]
 		else
 			walker->get_all_elements(libbash_string, $libbash_value);
 	}
+	|^(VAR_REF TIMES) { std::cerr << "$* has not been implemented yet" << std::endl; }
+	|^(VAR_REF AT) { std::cerr << "$@ has not been implemented yet" << std::endl; }
+	|^(VAR_REF POUND) { std::cerr << "$# has not been implemented yet" << std::endl; }
+	|^(VAR_REF QMARK) { $libbash_value = walker->get_status<std::string>(); }
+	|^(VAR_REF MINUS) { std::cerr << "$- has not been implemented yet" << std::endl; }
+	|^(VAR_REF BANG) { std::cerr << "$! has not been implemented yet" << std::endl; }
 	|^(VAR_REF libbash_string=var_expansion) { $libbash_value = libbash_string; };
 
 command

diff --git a/scripts/var_def.bash b/scripts/var_def.bash
index 56f8f8d..9b27dc3 100644
--- a/scripts/var_def.bash
+++ b/scripts/var_def.bash
@@ -35,3 +35,9 @@ ARRAY10="${ARRAY05[*]}"
 FOO001="networkmanager"
 FOO002="0.8.2"
 FOO003=${FOO001}-${FOO002}
+FOO004=$*
+FOO004=$@
+FOO004=$#
+FOO004=$?
+FOO004=$-
+FOO004=$!

diff --git a/scripts/var_def.bash.result b/scripts/var_def.bash.result
index 292b9c7..e840ebe 100644
--- a/scripts/var_def.bash.result
+++ b/scripts/var_def.bash.result
@@ -1,3 +1,8 @@
+$* has not been implemented yet
+$@ has not been implemented yet
+$# has not been implemented yet
+$- has not been implemented yet
+$! has not been implemented yet
 ARRAY01=1 2 3 4 5
 ARRAY02=1 2 4 5
 ARRAY03=2 3
@@ -18,6 +23,7 @@ EMPTY_ARRAY=
 FOO001=networkmanager
 FOO002=0.8.2
 FOO003=networkmanager-0.8.2
+FOO004=
 HOMEPAGE=http://sunpinyin.googlecode.com
 IUSE=
 KEYWORDS=~amd64 ~x86

diff --git a/src/core/interpreter.h b/src/core/interpreter.h
index 9d14f7d..5a90e53 100644
--- a/src/core/interpreter.h
+++ b/src/core/interpreter.h
@@ -485,6 +485,14 @@ public:
     set_value("?", status);
   }
 
+  /// \brief get the return status of the last command
+  /// \param the value of the return status
+  template <typename T=int>
+  T get_status(void)
+  {
+    return resolve<T>("?");
+  }
+
   /// \brief define a new global variable
   /// \param the name of the variable
   /// \param the value of the variable

diff --git a/test/script_compiler.sh b/test/script_compiler.sh
index d409673..021855e 100755
--- a/test/script_compiler.sh
+++ b/test/script_compiler.sh
@@ -4,7 +4,7 @@ declare -i error=0
 
 for script in $@
 do
-    ./variable_printer $script | diff -u $script.result -
+    ./variable_printer $script 2>&1 | diff -u $script.result -
     error+=$?
 done
 



             reply	other threads:[~2011-04-27 15:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27 15:11 Petteri Räty [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-04-14  4:50 [gentoo-commits] proj/libbash:master commit in: scripts/, src/core/, bashast/, test/ Petteri Räty
2011-04-14  4:50 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=33d754abccf45c6144be7341dcccca03623ad418.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