[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feat: exit 1 "file not found"
From: |
Dale R. Worley |
Subject: |
Re: feat: exit 1 "file not found" |
Date: |
Mon, 25 Mar 2024 14:20:31 -0400 |
teknopaul <teknopaul@fastmail.es> writes:
> Hi not sure if this is the correct forum...
I believe 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"
Well, you can get a similar effect tersely via
test -f file || { echo "file not found"; exit 2; }
but you may want to say
test -f file || { echo >&2 "file not found"; exit 2; }
And I think that may be the difficulty with making this an additional
function of "exit", there may well be too many variants in common use to
allow a simple extension to "exit" to cover the bulk of all uses. And
again, the present alternative has few disadvantages.
Dale