[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Manual descriptions for -a file and -e file
From: |
uzibalqa |
Subject: |
Re: Manual descriptions for -a file and -e file |
Date: |
Mon, 27 Mar 2023 06:51:06 +0000 |
------- Original Message -------
On Monday, March 27th, 2023 at 6:43 PM, Andreas Kusalananda Kähäri
<andreas.kahari@abc.se> wrote:
> On Mon, Mar 27, 2023 at 06:05:19AM +0000, uzibalqa wrote:
>
> > In the bash manual under "6.4 Bash Conditional Expressions" I see the
> > following.
> >
> > -a file
> > True if file exists.
> >
> > -e file
> > True if file exists.
> >
> > Could there be some brief comment about their difference?
>
>
> They are identical. This is the C code that detects when -a and -e is
> used:
It would help if the manual for "-a FILE" stated that it is equivalent to "-e
FILE".
>
> switch (op[1])
> {
> case 'a': /* file exists in the file system? */
> case 'e':
> return (sh_stat (arg, &stat_buf) == 0);
>
> That's from here:
> https://git.savannah.gnu.org/cgit/bash.git/tree/test.c#n526
>
> These two lines of code have been unchanged since 1996 (bash 1.14).
> There is no further clue in any commit messages, but I'm assuming this
> is to align with the original ksh shell, which also has these two test
> operators with the same semantics. Whe the ksh shell used both -a and
> -e, I don't know.
>
> The original Bourse shell did not have -e nor -a for testing whether
> a file exist. You had to some other test that not only tested for
> existence but also for e.g. readability, writability, file type or
> something else.
>
> --
> Andreas (Kusalananda) Kähäri
> SciLifeLab, NBIS, ICM
> Uppsala University, Sweden
>
> .