[Top][All Lists]

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

Re: -e and permission denied

From: Greg Wooledge
Subject: Re: -e and permission denied
Date: Thu, 3 Oct 2013 17:27:28 -0400
User-agent: Mutt/

On Thu, Oct 03, 2013 at 03:18:16AM -0700, address@hidden wrote:
> -e will return file not exists, even if it does, when permission denied error
> happen. I am wondering if this documented/correct behaviour or no.

I assume you mean that bash will return 1 (failure) for [[ -e /path/to/file ]]
when bash does not have search/execute privileges on all the directories
in /path/to/.  In which case, bash cannot stat() the file to see whether
it exists.

imadev:~$ mkdir -p /tmp/a/b/c 
imadev:~$ touch /tmp/a/b/c/file
imadev:~$ [[ -e /tmp/a/b/c/file ]]; echo $?
imadev:~$ chmod 000 /tmp/a/b/c
imadev:~$ [[ -e /tmp/a/b/c/file ]]; echo $?

How else would you expect bash to handle this?

reply via email to

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