Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [ltt-dev] [UST PATCH] Fix bug in test_functions.sh
@ 2010-09-21 11:54 Nils Carlson
  2010-09-21 13:02 ` David Goulet
  0 siblings, 1 reply; 5+ messages in thread
From: Nils Carlson @ 2010-09-21 11:54 UTC (permalink / raw)


As we were playing with OPTIND we managed to match the same
thing multiple times. Maybe make this more elegant in the
future.

Signed-off-by: Nils Carlson <nils.carlson at ericsson.com>
---
 tests/test_functions.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tests/test_functions.sh b/tests/test_functions.sh
index d27a734..40d4d89 100644
--- a/tests/test_functions.sh
+++ b/tests/test_functions.sh
@@ -40,6 +40,7 @@ function check_trace_logs() {
 
 
 function trace_matches() {
+    local OPTIND=
 
     RUNLTTV=~/devel/lttv/runlttv
 
-- 
1.7.1





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ltt-dev] [UST PATCH] Fix bug in test_functions.sh
  2010-09-21 11:54 [ltt-dev] [UST PATCH] Fix bug in test_functions.sh Nils Carlson
@ 2010-09-21 13:02 ` David Goulet
  2010-09-21 16:18   ` Nils Carlson
  0 siblings, 1 reply; 5+ messages in thread
From: David Goulet @ 2010-09-21 13:02 UTC (permalink / raw)


Hey Nils,

I don't understand here why you need to specify OPTIND as local. Isn't a 
global variable set by getops only used in the while loop..

Thanks
David

On 10-09-21 07:54 AM, Nils Carlson wrote:
> As we were playing with OPTIND we managed to match the same
> thing multiple times. Maybe make this more elegant in the
> future.
>
> Signed-off-by: Nils Carlson<nils.carlson at ericsson.com>
> ---
>   tests/test_functions.sh |    1 +
>   1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/tests/test_functions.sh b/tests/test_functions.sh
> index d27a734..40d4d89 100644
> --- a/tests/test_functions.sh
> +++ b/tests/test_functions.sh
> @@ -40,6 +40,7 @@ function check_trace_logs() {
>
>
>   function trace_matches() {
> +    local OPTIND=
>
>       RUNLTTV=~/devel/lttv/runlttv
>

-- 
David Goulet
LTTng project, DORSAL Lab.

PGP/GPG : 1024D/16BD8563
BE3C 672B 9331 9796 291A  14C6 4AF7 C14B 16BD 8563




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ltt-dev] [UST PATCH] Fix bug in test_functions.sh
  2010-09-21 13:02 ` David Goulet
@ 2010-09-21 16:18   ` Nils Carlson
  2010-09-22  6:58     ` Nils Carlson
  0 siblings, 1 reply; 5+ messages in thread
From: Nils Carlson @ 2010-09-21 16:18 UTC (permalink / raw)


On Sep 21, 2010, at 3:02 PM, David Goulet wrote:

> Hey Nils,
>
> I don't understand here why you need to specify OPTIND as local.  
> Isn't a global variable set by getops only used in the while loop..

Thought so too... but it didn't behave that way on my machine.

It's possible this is an issue with debian testing though. I'll try to  
check on ubuntu at home.

/Nils


> Thanks
> David
>
> On 10-09-21 07:54 AM, Nils Carlson wrote:
>> As we were playing with OPTIND we managed to match the same
>> thing multiple times. Maybe make this more elegant in the
>> future.
>>
>> Signed-off-by: Nils Carlson<nils.carlson at ericsson.com>
>> ---
>>  tests/test_functions.sh |    1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/tests/test_functions.sh b/tests/test_functions.sh
>> index d27a734..40d4d89 100644
>> --- a/tests/test_functions.sh
>> +++ b/tests/test_functions.sh
>> @@ -40,6 +40,7 @@ function check_trace_logs() {
>>
>>
>>  function trace_matches() {
>> +    local OPTIND=
>>
>>      RUNLTTV=~/devel/lttv/runlttv
>>
>
> -- 
> David Goulet
> LTTng project, DORSAL Lab.
>
> PGP/GPG : 1024D/16BD8563
> BE3C 672B 9331 9796 291A  14C6 4AF7 C14B 16BD 8563
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ltt-dev] [UST PATCH] Fix bug in test_functions.sh
  2010-09-21 16:18   ` Nils Carlson
@ 2010-09-22  6:58     ` Nils Carlson
  2010-09-22 14:09       ` David Goulet
  0 siblings, 1 reply; 5+ messages in thread
From: Nils Carlson @ 2010-09-22  6:58 UTC (permalink / raw)


Getting weirder and weirder...

This test fails on two of my machines:

#!/bin/bash

function optind_test() {

      while getopts "a:b:c:" flag; do
         case $flag in
             a) echo $OPTARG;;
             b) echo $OPTARG;;
             c) echo $OPTARG;;
         esac
      done
}

optind_test -a hi  -b thats nice
optind_test -c whats
echo ------


Adding a "local OPTIND=" after the function line makes everything work, 
but it shouldn't fail. According to POSIX OPTIND should be function local 
already.

/Nils


On Tue, 21 Sep 2010, Nils Carlson wrote:

> On Sep 21, 2010, at 3:02 PM, David Goulet wrote:
>
>> Hey Nils,
>>
>> I don't understand here why you need to specify OPTIND as local.
>> Isn't a global variable set by getops only used in the while loop..
>
> Thought so too... but it didn't behave that way on my machine.
>
> It's possible this is an issue with debian testing though. I'll try to
> check on ubuntu at home.
>
> /Nils
>
>
>> Thanks
>> David
>>
>> On 10-09-21 07:54 AM, Nils Carlson wrote:
>>> As we were playing with OPTIND we managed to match the same
>>> thing multiple times. Maybe make this more elegant in the
>>> future.
>>>
>>> Signed-off-by: Nils Carlson<nils.carlson at ericsson.com>
>>> ---
>>>  tests/test_functions.sh |    1 +
>>>  1 files changed, 1 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/tests/test_functions.sh b/tests/test_functions.sh
>>> index d27a734..40d4d89 100644
>>> --- a/tests/test_functions.sh
>>> +++ b/tests/test_functions.sh
>>> @@ -40,6 +40,7 @@ function check_trace_logs() {
>>>
>>>
>>>  function trace_matches() {
>>> +    local OPTIND=
>>>
>>>      RUNLTTV=~/devel/lttv/runlttv
>>>
>>
>> --
>> David Goulet
>> LTTng project, DORSAL Lab.
>>
>> PGP/GPG : 1024D/16BD8563
>> BE3C 672B 9331 9796 291A  14C6 4AF7 C14B 16BD 8563
>>
>> _______________________________________________
>> ltt-dev mailing list
>> ltt-dev at lists.casi.polymtl.ca
>> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>
>




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ltt-dev] [UST PATCH] Fix bug in test_functions.sh
  2010-09-22  6:58     ` Nils Carlson
@ 2010-09-22 14:09       ` David Goulet
  0 siblings, 0 replies; 5+ messages in thread
From: David Goulet @ 2010-09-22 14:09 UTC (permalink / raw)


Yes you are right... Same problem here even with the shift optind-1...

Well, we are sure that on Debian AND Ubuntu, it's a problem so I guess 
this patch is *very* useful ;)

Cheers
David

On 10-09-22 02:58 AM, Nils Carlson wrote:
> Getting weirder and weirder...
>
> This test fails on two of my machines:
>
> #!/bin/bash
>
> function optind_test() {
>
> while getopts "a:b:c:" flag; do
> case $flag in
> a) echo $OPTARG;;
> b) echo $OPTARG;;
> c) echo $OPTARG;;
> esac
> done
> }
>
> optind_test -a hi -b thats nice
> optind_test -c whats
> echo ------
>
>
> Adding a "local OPTIND=" after the function line makes everything work,
> but it shouldn't fail. According to POSIX OPTIND should be function
> local already.
>
> /Nils
>
>
> On Tue, 21 Sep 2010, Nils Carlson wrote:
>
>> On Sep 21, 2010, at 3:02 PM, David Goulet wrote:
>>
>>> Hey Nils,
>>>
>>> I don't understand here why you need to specify OPTIND as local.
>>> Isn't a global variable set by getops only used in the while loop..
>>
>> Thought so too... but it didn't behave that way on my machine.
>>
>> It's possible this is an issue with debian testing though. I'll try to
>> check on ubuntu at home.
>>
>> /Nils
>>
>>
>>> Thanks
>>> David
>>>
>>> On 10-09-21 07:54 AM, Nils Carlson wrote:
>>>> As we were playing with OPTIND we managed to match the same
>>>> thing multiple times. Maybe make this more elegant in the
>>>> future.
>>>>
>>>> Signed-off-by: Nils Carlson<nils.carlson at ericsson.com>
>>>> ---
>>>> tests/test_functions.sh | 1 +
>>>> 1 files changed, 1 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/tests/test_functions.sh b/tests/test_functions.sh
>>>> index d27a734..40d4d89 100644
>>>> --- a/tests/test_functions.sh
>>>> +++ b/tests/test_functions.sh
>>>> @@ -40,6 +40,7 @@ function check_trace_logs() {
>>>>
>>>>
>>>> function trace_matches() {
>>>> + local OPTIND=
>>>>
>>>> RUNLTTV=~/devel/lttv/runlttv
>>>>
>>>
>>> --
>>> David Goulet
>>> LTTng project, DORSAL Lab.
>>>
>>> PGP/GPG : 1024D/16BD8563
>>> BE3C 672B 9331 9796 291A 14C6 4AF7 C14B 16BD 8563
>>>
>>> _______________________________________________
>>> ltt-dev mailing list
>>> ltt-dev at lists.casi.polymtl.ca
>>> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>>
>>

-- 
David Goulet
LTTng project, DORSAL Lab.

PGP/GPG : 1024D/16BD8563
BE3C 672B 9331 9796 291A  14C6 4AF7 C14B 16BD 8563




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-09-22 14:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-21 11:54 [ltt-dev] [UST PATCH] Fix bug in test_functions.sh Nils Carlson
2010-09-21 13:02 ` David Goulet
2010-09-21 16:18   ` Nils Carlson
2010-09-22  6:58     ` Nils Carlson
2010-09-22 14:09       ` David Goulet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox