[Top][All Lists]

[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: Peng Yu
Subject: Re: How to make "division by zero attempted" error message more informative?
Date: Thu, 3 Mar 2022 12:09:13 -0600

Sorry. I accidentally sent the email to the bug mailing list. It
should be sent to the help mailing list.

On 3/3/22, Ed Morton <> wrote:
> 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.

The problem is that if this piece code is embedded inline in many bash
scripts, it will be very hard to find where the error is from.

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

Maybe there can be a prefix to the error message that the users can control?

>      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]