Libelektra: Build: AWK Warnings

Created on 23 Nov 2019  ·  6Comments  ·  Source: ElektraInitiative/libelektra

Steps to Reproduce the Problem

  1. Build the Docker image for Debian sid
  2. Run the container
  3. Build Elektra using the commands below:

    mkdir build
    cmake -G Ninja -B build
    cmake --build build
    

Expected Result

The last command does not print any warning or error messages.

Actual Result

The command cmake --build build prints the following warning messages:

Generating ../../../../include/gen/templates.hpp
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator
awk: cmd. line:12: warning: regexp escape sequence `\"' is not a known regexp operator

System Information

  • Elektra Version: master
  • Docker 2.1.0.5

Further Information

As far as I can tell the problem is the line:

https://github.com/ElektraInitiative/libelektra/blob/ba8ffe00c0735610a4b6c5f4af57e6ca7c207dfd/src/tools/kdb/gen/templates/collect.sh#L18

. Looks like we should remove the \ before the first ". I am not sure that is the right option though, since I do not understand why the character set ([]) contains multiple double and single quotes.

bug build cleanup lanshell low priority

All 6 comments

Thank you for reporting the problem!

I do not know if this is a "good first issue" if you are not sure yourself what is meant?

I do not know if this is a "good first issue" if you are not sure yourself what is meant?

I am pretty sure it would be a “good first issue“ for an awk programmer 😊. Anyway, I removed the label for now.

since I do not understand why the character set ([]) contains multiple double and single quotes.

The line in question is part of a single quoted string in a shell script. Therefore the sequence '"'"' closes the single quoted string ', opens a double quoted one ", adds a single quote to the double quoted string ', closes the double quoted string " and opens a single quoted string '. Together this just adds the a single quote to the single quoted string.
The double quote before that is there to add a double quote to the character set.

It seems the warning wants us to replace \" with ". If we do that we need to make sure that it still works with both gawk and mawk. Sometimes they disagree. The POSIX standard says \" is correct. (here the table under Regular Expressions)

If the POSIX standard says contrary to the warning it might be better to ignore the warning.

If the POSIX standard says contrary to the warning it might be better to ignore the warning.

While following POSIX sounds good, at least the awk implementations I tested (nawk, gawk, bioawk, and mawk) seem to have no problem with unescaped double quotes. At least the script

#!/usr/bin/env sh

#      BWK awk/nawk/
#      One true awk           gawk
set -- /usr/bin/awk /usr/local/bin/awk bioawk mawk

for awk; do
    printf '"bla\nblubb' | "$awk" '$0 ~ /["].*/ { print $0 }'
done

prints the same line:

"bla

four times on my machine. I already removed the backslash locally and will probably open a pull request that contains this minor “fix” and some other minor improvements in the next days.

We are really spending a lot of time on a very unimportant issue. There are many other important issues :wink:

I already removed the backslash locally and will probably open a pull request that contains this minor “fix” and some other minor improvements in the next days.

Good! :sparkle:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dominicjaeger picture dominicjaeger  ·  3Comments

mpranj picture mpranj  ·  3Comments

mpranj picture mpranj  ·  3Comments

markus2330 picture markus2330  ·  4Comments

markus2330 picture markus2330  ·  4Comments