[Top][All Lists]

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

Re: Bash -f Test Operator - Not working as expected

From: Eduardo Bustamante
Subject: Re: Bash -f Test Operator - Not working as expected
Date: Mon, 1 May 2017 23:24:44 -0500

On Mon, May 1, 2017 at 8:52 PM, Eduardo Bustamante <address@hidden> wrote:
> On Sat, Apr 29, 2017 at 8:56 PM, Adam Danischewski
> <address@hidden> wrote:
>> In the documentation you linked to it says:
>> -f file
>> True if file exists and is a regular file.
>> The part of the documentation you cited states "Unless otherwise specified"
>> - it is otherwise specified where it states "and is a regular file". It
>> simply doesn't behave that way.
> Your not interpreting the document correctly. The test will first
> resolve a chain of symbolic links, and operate on the target. There's
> no exception mentioned for the -f primary.
> For the behavior you want, you need something like:
>   test ! -h "$pathname" -a -f "$pathname"
> If you're still not convinced by the bash reference manual, then read
> the POSIX specification for the test command:
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
> "With the exception of the -h pathname and -L pathname primaries, if a
> pathname argument is a symbolic link, test shall evaluate the
> expression by resolving the symbolic link and using the file
> referenced by the link."

I had not realized bug-bash wasn't CC'ed.

reply via email to

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