|
From: Branden A. <b.m...@gm...> - 2015-12-23 17:55:03
|
The example is helpful, thanks.
I find that on OSX that using either single or double slashes works just
fine. The unit tests for checkmk also work with the double slashes on OSX
and GNU/Linux.
Thanks for the patch. It has been committed and your name mentioned in the
AUTHORS file. The change will appear in the next release of Check.
- Branden
On Wed, Dec 23, 2015 at 10:22 AM, Morris, James <jm...@us...> wrote:
> Hi Brandon,
>
> Solaris 10 uses a single backslash to escape characters. However, checkmk
> declares regular expressions in variables and the strings were quoted using
> double quotes. So, awk turns the \n into a real newline before it gets run
> through the regex parser. This is an example script called testme1
> illustrating the Solaris awk:
>
> --------- CUT ME -----------------
> #!/usr/bin/nawk -f
>
> BEGIN {
> RS=" ";
> a="[\a\n]";
> z="[\n]";
> }
>
> $0 ~ a {print "matched a"}
> $0 ~ z {print "matched z"}
> --------- CUT ME -----------------
>
> > printf "\a\n" | ./testme1
> /usr/bin/nawk: newline in character class [
> ]...
> input record number 1
> source line number 9
>
> Example script called testme2 where the special characters are escaped:
>
> --------- CUT ME -----------------
> #!/usr/bin/nawk -f
>
> BEGIN {
> RS=" ";
> a="[\\a\\n]";
> z="[\\n]";
> }
>
> $0 ~ a {print "matched a"}
> $0 ~ z {print "matched z"}
> --------- CUT ME -----------------
>
> > printf "\a\n" | .testme2
> matched a
> matched z
>
> Does this help?
> Jim
>
> On Tue, Dec 22, 2015 at 10:55 PM, Branden Archer <b.m...@gm...>
> wrote:
>
>> James,
>>
>> Thanks for the patch, and sorry for not getting around to it before now.
>>
>> Can you describe why the patch is necessary? Namely, does the awk on
>> Solaris not work as it does on GNU/Linux with respect to escapes in strings
>> for regular expressions?
>>
>> I'm not as familiar with awk, so I attempted a little experiment to see
>> how awk on my system works when either escaping a special character with
>> one slash:
>>
>> $ printf "\a" | xxd
>> 0000000: 07 .
>> $ printf "\a" | awk '{if ($0 ~ "[\a]") print }' | xxd
>> 0000000: 070a ..
>> $
>>
>> or with two slashes:
>>
>> $ printf "\a" | xxd
>> 0000000: 07 .
>> $ printf "\a" | awk '{if ($0 ~ "[\\a]") print }' | xxd
>> $
>>
>> The behavior is different. Namely, at least for OSX escaping with two
>> slashes does not match the bell character, but escaping with one slash does.
>>
>> Does this behavior match that on Solaris, or is it the opposite? If so,
>> is there gawk <https://www.gnu.org/software/gawk/> available on your
>> system which could be used instead?
>>
>> - Branden
>>
>> On Fri, Dec 4, 2015 at 2:49 PM, Morris, James <jm...@us...> wrote:
>>
>>> I have attached a patch for checkmk so the awk script will run under
>>> Solaris. This is for version 0.10.0.
>>>
>>> Jim
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Go from Idea to Many App Stores Faster with Intel(R) XDK
>>> Give your users amazing mobile app experiences with Intel(R) XDK.
>>> Use one codebase in this all-in-one HTML5 development environment.
>>> Design, debug & build mobile apps & 2D/3D high-impact games for multiple
>>> OSs.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
>>> _______________________________________________
>>> Check-devel mailing list
>>> Che...@li...
>>> https://lists.sourceforge.net/lists/listinfo/check-devel
>>>
>>>
>>
>
|