Closed GoogleCodeExporter closed 9 years ago
It seems that this isn't the only thing that needs to be changed, because it
doesn't seem to work when I tried it again.
Original comment by hulselma...@gmail.com
on 31 Oct 2011 at 3:27
[deleted comment]
I found the problem:
$ git format-patch --stdout 719cdee604ce9a5d815de116e9bfa7491a37ebf3
From 3f54ddc09aa09442a9601f9a019c30b6099ce2ad Mon Sep 17 00:00:00 2001
From: Gert Hulselmans <hulselmansgert@gmail.com>
Date: Mon, 31 Oct 2011 17:51:43 +0100
Subject: [PATCH] ppss: Add support for ${ITEM} in the command line.
Add support for ${ITEM} in the command line.
${ITEM} is a valid bash variable, just like $ITEM.
Using ${ITEM} in the command line, allows do to string operations:
http://tldp.org/LDP/abs/html/refcards.html
The grep command is rewritten in awk because grep -E (extended regular
expression)
seems to require that everything is escaped twice when run from ppss:
`echo $COMMAND | grep -E -i '\\$\\{?ITEM' >> /dev/null 2>&1`
On the command line, the following work fine:
`echo $COMMAND | grep -E -i '\$\{?ITEM' >> /dev/null 2>&1`
---
ppss | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/ppss b/ppss
index a3af490..5df9c6e 100755
--- a/ppss
+++ b/ppss
@@ -2175,7 +2175,12 @@ commando () {
# the -c option.
#
BEFORE=`get_time_in_seconds`
- `echo $COMMAND | grep -i '$ITEM' >> /dev/null 2>&1`
+
+ # Check for "$ITEM" or "${ITEM" in the command line.
+ # Return error code value 1, when "$ITEM" or "${ITEM" is not found,
+ # else return error code value 0.
+ `echo $COMMAND | awk '$0 !~ /\$\{?ITEM/ {exit 1}' >> /dev/null 2>&1`
+
RETVAL="$?"
if [ "$RETVAL" = "0" ]
then
--
1.7.0.4
Original comment by hulselma...@gmail.com
on 31 Oct 2011 at 4:59
The problem seems to be caused by the backticks.
The invocation of a subshell for the grep command looks unnecessary to me.
From 877e3d38ebdc037664950ac8bd2e25a993166458 Mon Sep 17 00:00:00 2001
From: Gert Hulselmans <hulselmansgert@gmail.com>
Date: Mon, 31 Oct 2011 17:51:43 +0100
Subject: [PATCH] ppss: Add support for ${ITEM} in the command line.
Add support for ${ITEM} in the command line.
${ITEM} is a valid bash variable, just like $ITEM.
Using ${ITEM} in the command line, allows do to string operations:
http://tldp.org/LDP/abs/html/refcards.html
Use grep with extended regular expression support (grep -E) to look for
$ITEM and ${ITEM at the same time.
Remove trouble causing backticks, because this requires double escaping.
The command doesn't need to be executed in a subshell.
---
ppss | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/ppss b/ppss
index a3af490..7a6a0af 100755
--- a/ppss
+++ b/ppss
@@ -2175,7 +2175,12 @@ commando () {
# the -c option.
#
BEFORE=`get_time_in_seconds`
- `echo $COMMAND | grep -i '$ITEM' >> /dev/null 2>&1`
+
+ # Check for "$ITEM" or "${ITEM" in the command line.
+ # Grep returns error code 0, when the string is found.
+ # When the string isn't found, error code 1 is returned.
+ echo $COMMAND | grep -E -i '\$\{?ITEM' >> /dev/null 2>&1
+
RETVAL="$?"
if [ "$RETVAL" = "0" ]
then
--
1.7.0.4
Original comment by hulselma...@gmail.com
on 3 Nov 2011 at 11:00
Thx, now in new version.
Original comment by Louwrentius
on 25 Dec 2011 at 4:44
[deleted comment]
I saw that in you commit, you kept the backslashes.
Are you sure it works in that case?
Did you test with $ITEM and ${ITEM}?
Original comment by hulselma...@gmail.com
on 26 Dec 2011 at 11:36
Original issue reported on code.google.com by
hulselma...@gmail.com
on 31 Oct 2011 at 10:02