Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15523

-e test description in the GNU Bash 5.0 man page from 7 December 2018

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Marco Ippolito <maroloccio@gmail.com>
Newsgroups gnu.bash.bug
Subject -e test description in the GNU Bash 5.0 man page from 7 December 2018
Date Mon, 21 Oct 2019 00:31:41 +0200
Lines 71
Approved bug-bash@gnu.org
Message-ID <mailman.1341.1571619692.9715.bug-bash@gnu.org> (permalink)
References <6f5fd3b2-2e3b-4730-b2d8-50b89e9e3085@gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace usenet.stanford.edu 1571619692 31390 209.51.188.17 (21 Oct 2019 01:01:32 GMT)
X-Complaints-To action@cs.stanford.edu
To chet.ramey@case.edu, bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=SAczVATJFbeK85esQVzhM3CyZeFc/MsyVrsy5RXdRY4=; b=n9E/uGAhy+dThdSDhCmc/I16r71vS4t8oqMDJTHF35YwwJ+YqmxyQ/2j1QaVpDGX8z dHQZfQ2jAdysVrVPJ01JlDsI/oMODND9qVBcuRzLOYjOh8BQ85tT3z5rzTaTtr8C5qgK TmSMKapPQl0ZHejzqIcZAi/2fuIOOcljSJLA1/sbkcq3HqusgLPpZbyFRJPMKlkNk4zm TWZHKauQEPb1ag/hOsIt1KgAdP8jWA0ceBpD9q5hIPX1OzuLTR4Sd4QFIU0FtLJA8/O0 xJmhvX2DjEvbJ9XcJLVKJJqsd9ti37d7fqpeOYx8OSIF8gBWmSNeQSMOwh85EtzyWzKz qBHg==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=SAczVATJFbeK85esQVzhM3CyZeFc/MsyVrsy5RXdRY4=; b=paGICLbF/E5LA3a5GVDSqTX7mZM5eEwEosYNvQ6xIaAtw9Yrl2fuDWA5p+lNZ/HNVx BSqwmjQphn8+XgTN+NM2jWbzUCVpyDX8tbyHlFzHUyGUsP0Fk9CMG0nc20QR9IK5pFBq KTWMBWgTT3SjqI2nBR+D0GAZMFPo0qttJxuqX+FF6NHwCny2DPE1k4mKGpPo/dWC5Piw dqgHWREZ+ZoFNocDuBQMYp3Rv3STzvlXGy+rat52w/kflTg1WpiU5EQMJcM/mnKi0NOw F9OFLvNDZ0uz0yHrhJ7lBttNfO6BSIeYbKSML5/7JAG5jbRKeqfrejmAgoD4PXd24BGu P/gQ==
X-Gm-Message-State APjAAAV/wxqEQTIl8tPjahPWwm+jv6oU5hghtJZX5o6mlJBUsff7aMPH 3Q2PZUdl8lmGSBQ/EXc6xZHEiGvz
X-Google-Smtp-Source APXvYqxciny/LTPC63jFBEoWGqdScLWEaL15JEUzw6I20AikABxSHzpi5etZGbfYgLJMoaFP9leQuA==
X-Received by 2002:a5d:5704:: with SMTP id a4mr16033718wrv.281.1571610704658; Sun, 20 Oct 2019 15:31:44 -0700 (PDT)
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0
Content-Language en-GB
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2a00:1450:4864:20::442
X-Mailman-Approved-At Sun, 20 Oct 2019 21:01:30 -0400
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <6f5fd3b2-2e3b-4730-b2d8-50b89e9e3085@gmail.com>
Xref csiph.com gnu.bash.bug:15523

Show key headers only | View raw


In the GNU Bash 5.0 man page from 7 December 2018 the -e test is 
documented as such:

        -e file
               True if file exists.

When "file" is a symlink name to a non-existing target, the -e test 
fails, and this may be surprising from just reading the documentation.

By contrast, POSIX describes the same test as follows:

         -e pathname
   True if pathname resolves to an existing directory entry. False if
    pathname cannot be resolved.

POSIX provides an indication as to the potential failure of the test in 
contexts in which symlink *resolution* is performed.

It might be beneficial to reword this Linux man page.

It *may* also be beneficial to change the use of "file" in the GNU man 
page to refer to pathnames, as POSIX does, so that the distinction 
between "files" and "regular files" be more explicit.

Observe this test description on the GNU man page, for example:

        -f file
               True if file exists and is a regular file.

Here is a sample GNU script illustrating the tests alluded to above:

#! /usr/bin/env bash

# Run me on GNU/Linux

cd "$(mktemp --directory)"

touch existing_file

ln --symbolic existing_file symlink_to_existing_file
ln --symbolic non_existing_file symlink_to_non_existing_file
ln --symbolic symlink_to_existing_file symlink_to_symlink_to_existing_file
ln --symbolic symlink_to_non_existing_file symlink_to_unresolvable_symlink

{
     for pathname in \
         existing_file \
         symlink_to_existing_file \
         symlink_to_non_existing_file \
         symlink_to_symlink_to_existing_file \
symlink_to_unresolvable_symlink
do
         if [[ -e $pathname ]]; then
existence=exists
else
             existence='does not exist'
fi
         printf '[[ -e %s ]] \x1f -> \x1f %s\n' "$pathname" "$existence"
done;
} | column -t -s $'\x1f'

Outputs:

[[ -e existing_file ]]                          -> exists
[[ -e symlink_to_existing_file ]]               ->    exists
[[ -e symlink_to_non_existing_file ]]           ->    does not exist
[[ -e symlink_to_symlink_to_existing_file ]]    ->    exists
[[ -e symlink_to_unresolvable_symlink ]]        ->    does not exist


Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

-e test description in the GNU Bash 5.0 man page from 7 December 2018 Marco Ippolito <maroloccio@gmail.com> - 2019-10-21 00:31 +0200

csiph-web