FedoraForum.org - Fedora Support Forums and Community
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    415

    SOLVED: awk illegal statement ignored

    In an awk BEGIN section, I intended to write something like:
    zcmd = "rm -v " zfile
    However, I omitted the "=". The program runs (but not correctly), with that statement being silently ignored. I would expect some kind of error message, like "illegal statement", or "syntax error".

    I'm guessing that such a statement, outside of a BEGIN or END section, could be taken as a pattern, and since it isn't followed by an action, a null action could be assumed. But that doesn't apply within a BEGIN or END section, to the best of my understanding.

    gawk, mawk, and nawk all silently ignore a statement like that, though for a statement like "date" on a line by itself, nawk complains of an illegal statement, but doesn't complain if the statement is a "concatenation" like:
    "date " zdate, or maybe it's being interpreted as <pattern> <action>?

    Is there something I'm missing, that such a construct could actually be functional (within a BEGIN or END)?
    Last edited by dswaner; 16th January 2018 at 03:42 PM.

  2. #2
    Join Date
    Nov 2008
    Posts
    415

    Re: awk illegal statement ignored

    I submitted a RFE for gawk, to flag such statements as errors: https://bugzilla.redhat.com/show_bug.cgi?id=1520145

  3. #3
    Join Date
    Nov 2008
    Posts
    415

    Re: awk illegal statement ignored

    Result of RFE: such errors are reported by using the awk --lint option, so this suggestion got a WONTFIX. I personally think that users should see all error messages by default, and then if they don't want to see warning messages, set an option to turn them off.

    Additional thoughts:
    The default behavior is probably best for the casual awk user, and changing the default behavior now would result in spamming end users with irrelevant warning messages from numerous existing scripts.
    Last edited by dswaner; 8th December 2017 at 09:38 PM. Reason: Additional thoughts

Similar Threads

  1. more than two conditions in an %if statement
    By PatMcDonagh in forum Programming & Packaging
    Replies: 1
    Last Post: 8th November 2011, 11:50 PM
  2. Python with statement
    By IHeart SymLinks in forum Programming & Packaging
    Replies: 1
    Last Post: 30th March 2011, 07:35 PM
  3. Switch statement
    By teishu in forum Programming & Packaging
    Replies: 3
    Last Post: 12th February 2007, 03:47 PM
  4. if statement in bash
    By Adesso in forum Programming & Packaging
    Replies: 1
    Last Post: 1st September 2006, 03:33 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •