[Slackbuilds-users] Default Slackware 'gawk' build options affecting output?

Rich Shepard rshepard at appl-ecosys.com
Mon Jul 23 16:01:16 UTC 2018


   In a gawk script I'm writing I need to use the switch statment. This web
page,
<http://gnu.ist.utl.pt/software/gawk/manual/html_node/Switch-Statement.html>,
says, "This subsection describes an experimental feature added in gawk
3.1.3. It is not enabled by default. To enable it, use the --enable-switch
option to configure when gawk is being configured and built."

   Looking at the 14.2 gawk-4.1.3 slackbuild script at
<https://slackware.osuosl.org/slackware-14.2/source/a/gawk/gawk.SlackBuild>
switch is not enabled; no options are enabled.

   Should I rebuild gawk-4.1.3 enabling switch?

   This is the syntax errors I see when I run the script:

$ gawk -f trim-fields.awk longform > trimmed
gawk: trim-fields.awk:14: switch NR {
gawk: trim-fields.awk:14: ^ syntax error
gawk: trim-fields.awk:15: case 36: # No shifts present.
gawk: trim-fields.awk:15: ^ syntax error
gawk: trim-fields.awk:18: case 37: # 1 shift present.
gawk: trim-fields.awk:18: ^ syntax error
gawk: trim-fields.awk:21: case 38: # 2 shifts present.
gawk: trim-fields.awk:21: ^ syntax error
gawk: trim-fields.awk:24: case ?:
gawk: trim-fields.awk:24: ^ syntax error

   And this is the script:

# Get line length (number of fields)
switch NR {
case 36: # No shifts present.
     { print $1, $6, $7, $8, $9, $10, $11, $12, $13, $18, $19, $20, $21, $22, $23, $24, $25, $29, $30, $31, $32, $33, $34, $35, $36 }
     break
case 37: # 1 shift present.
     { print $1, $6, $7, $8, $9, $10, $11, $12, $13, $19, $20, $21, $22, $23, $24, $25, $26, $30, $31, $32, $33, $34, $35, $36, $37 }
     break
case 38: # 2 shifts present.
     { print $1, $7, $8, $9, $10, $11, $12, $13, $14, $20, $21, $22, $23, $24, $25, $26, $27, $31, $32, $33, $34, $35, $36, $37, $38 }
     break
case ?:
     break
}

   The syntax is based on "Effective awk Programming, 4th Ed." by Arnold
Robbins, page 154.

Rich



More information about the SlackBuilds-users mailing list