[Top][All Lists]

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

Re: extension of file-test primitives?

From: PePa
Subject: Re: extension of file-test primitives?
Date: Sun, 20 Aug 2017 08:52:47 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

In that case, would not [[ =fx $file ]] be more workable and in line with common GNU short commandline option practice??


On 08/20/2017 07:30 AM, L A Walsh wrote:
Curious, but how difficult or problematic would it be
to allow using brace-expansion (ex. {f,x} ) as a short-hand
to test/combine file-op tests like:


   test -{f,x} /bin/ls && ...
    if [[ -{f,x} $file ]]; then ... ; fi

instead of:

   test -f /bin/ls && test -x /bin/ls && ...


(maybe boring background):
Came from a spur-of-the-moment experimenting with bash equivalents
to perl's file-op chaining, like:

  if (-f -x "/bin/ls") { ... }

and came up with something a bit odd but working, but
a bit quirky looking for a lib-type function or alias:

  eval 'test -'{f,x}' /bin/ls && :' && echo executable file

and wondered if bash might adopt some shortcut for testing
multiple flags or if it was too specialized for such a minor

just a minor curiosity if code was submitted...etc...etc...?

reply via email to

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