bug-bash
[Top][All Lists]
Advanced

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

File test -a and -e do not behave as described in the man page.


From: Alexander Blazej
Subject: File test -a and -e do not behave as described in the man page.
Date: Sat, 8 May 2004 10:36:38 -0700 (PDT)

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H  -I.  -I../bash -I../bash/include 
-I../bash/lib  -g -O2
uname output: Linux satyr 2.6.6-rc3+satyr.32 #1 Sun May 2 14:12:51 PDT 2004 
i686 GNU/Linux
Machine Type: i386-pc-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:
        The man page section "CONDITIONAL EXPRESSIONS" contains:
       -a file
              True if file exists.
       -e file
              True if file exists.
        However their behavior is different.  Please correctly document "-a".

Repeat-By:

#!/bin/bash


ERRORS=0
REGULAR_FILE="`mktemp regular.XXXXXX`"
SYMLINK_FILE="symlink_to-${REGULAR_FILE}"

touch "${REGULAR_FILE}"
ln -s "${REGULAR_FILE}" "${SYMLINK_FILE}"

ls -lFA "${REGULAR_FILE}"
ls -lFA "${SYMLINK_FILE}"

if [ -e "${SYMLINK_FILE}" ]; then
        echo "-e says exists ${SYMLINK_FILE}"
else
        echo "ERROR: -e says absent ${SYMLINK_FILE}"
        ERRORS=`expr ${ERRORS} + 1`
fi

if [ -a "${SYMLINK_FILE}" ]; then
        echo "-a says exists ${SYMLINK_FILE}"
else
        echo "ERROR: -a says absent ${SYMLINK_FILE}"
        ERRORS=`expr ${ERRORS} + 1`
fi

if [ ! -e "${SYMLINK_FILE}" ]; then
        echo "ERROR: ! -e says absent ${SYMLINK_FILE}"
        ERRORS=`expr ${ERRORS} + 1`
else
        echo "! -e says exists ${SYMLINK_FILE}"
fi

if [ ! -a "${SYMLINK_FILE}" ]; then
        echo "ERROR: ! -a says absent ${SYMLINK_FILE}"
        ERRORS=`expr ${ERRORS} + 1`
else
        echo "! -a says exists ${SYMLINK_FILE}"
fi

rm $REGULAR_FILE

echo Number of errors: ${ERRORS}
if [ ${ERRORS} > 0 ]; then
        exit 1
else
        exit 0
fi

Fix:
        [Description of how to fix the problem.  If you don't know a
        fix for the problem, don't include this section.]




reply via email to

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