[Top][All Lists]

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

extension of file-test primitives?

From: L A Walsh
Subject: extension of file-test primitives?
Date: Sat, 19 Aug 2017 17:30:34 -0700
User-agent: Thunderbird

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]