bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make "division by zero attempted" error message more informat


From: Ed Morton
Subject: Re: How to make "division by zero attempted" error message more informative?
Date: Thu, 3 Mar 2022 11:04:43 -0600
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1

That error message tells you the line number in the script (`line:1`), the input file name (`FILENAME=-`), and the line number in the input file where the error occurred (`FNR=1`) as well as telling you it's a divide by zero and you can clearly see in your code where you're dividing so I'm not sure what more information could be needed/provided.

Out of curiosity though - what would you like the error message to say?

    Ed.

On 3/3/2022 6:46 AM, Peng Yu wrote:
I see something like this. But when this kind of command is called at
multiple scripts. It is hard to tell where the error is from.

$ awk -e '{ print 10/$1 }' <<< 0
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: division by zero attempted

Is there a way to customize the error message so that I can know where the
error is coming from? Thanks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]