bug-bash
[Top][All Lists]
Advanced

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

feat: exit 1 "file not found"


From: teknopaul
Subject: feat: exit 1 "file not found"
Date: Fri, 22 Mar 2024 20:29:18 +0100
User-agent: Cyrus-JMAP/3.11.0-alpha0-332-gdeb4194079-fm-20240319.002-gdeb41940

Hi not sure if this is the correct forum...

exit builtin accepts one and only one arg currently.

Would it be backwards compatible and generally useful to support echoing a 
reason for exiting?

test -f file || exit 2 "file not found"

good bash scripters handle and report errors

 have seen lots of functions in the wild like

function die() {
  echo $@
  exit 1
} 

function die() {
  code=$1
  shift
  echo $@
  exit $code
} 

but none has made its way to a reliably available default, so its oft repeated, 
and more often omitted so failure prints nothing.

Could it be a candidate for an extension to bash's exit builtin?  I don't think 
anything existing would break, currently we get too many args and it does not 
exit



reply via email to

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