Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.92k stars 551 forks source link

prefix errors with name of program #7260

Closed p5pRT closed 20 years ago

p5pRT commented 20 years ago

Migrated from rt.perl.org#29094 (status was 'resolved')

Searchable as RT29094$

p5pRT commented 20 years ago

From @jidanni

Today again lots of head scratching because bash and perl don't prefix their error messages with a "bash​:" or a "perl​:"\, so bash scripts with bits of perl often take deep scrutinization to figure out what the problem was.

It's as if each author never expected any embedding of scripts. Make might call bash might call perl. Make says "make​:"\, but highfalutin bash and perl act like "why of course\, were you expecting to be running something else?"

p5pRT commented 20 years ago

From @iabyn

On Fri\, Apr 23\, 2004 at 06​:00​:06AM -0000\, Dan Jacobson wrote​:

Today again lots of head scratching because bash and perl don't prefix their error messages with a "bash​:" or a "perl​:"\, so bash scripts with bits of perl often take deep scrutinization to figure out what the problem was.

That may well be the case\, but Perl has done its error messages this way for 16 years\, and changing it now would boringly break lots of things.

If you're really desperate for this feature\, you can do something like this​:

  $ ./perl -e '$SIG{__DIE__}=sub{print STDERR"Perl​: "\,@​_;exit 1}; $x/=$y'   Perl​: Illegal division by zero at -e line 1.

-- The Enterprise successfully ferries an alien VIP from one place to another without serious incident.   -- Things That Never Happen in "Star Trek" #7

p5pRT commented 20 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 20 years ago

@iabyn - Status changed from 'open' to 'resolved'

p5pRT commented 20 years ago

From @ysth

On Mon\, May 03\, 2004 at 10​:47​:27PM +0100\, Dave Mitchell \davem@​iabyn\.com wrote​:

On Fri\, Apr 23\, 2004 at 06​:00​:06AM -0000\, Dan Jacobson wrote​:

Today again lots of head scratching because bash and perl don't prefix their error messages with a "bash​:" or a "perl​:"\, so bash scripts with bits of perl often take deep scrutinization to figure out what the problem was.

That may well be the case\, but Perl has done its error messages this way for 16 years\, and changing it now would boringly break lots of things.

If you're really desperate for this feature\, you can do something like this​:

$ \./perl \-e '$SIG\{\_\_DIE\_\_\}=sub\{print STDERR"Perl​: "\,@​\_;exit 1\}; $x/=$y'
Perl​: Illegal division by zero at \-e line 1\.

That requires that you already suspect that it is a perl error\, in which case you can look it up via man perldiag (or pipe the error to the splain utility to do it for you). perldiag contains (we hope) all perl issued error messages\, as well as\, for convenience\, many shell errors that can result from erroneously feeding perl code to a shell.