bug-bash
[Top][All Lists]
Advanced

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

Re: extension of file-test primitives?


From: Pierre Gaston
Subject: Re: extension of file-test primitives?
Date: Wed, 23 Aug 2017 16:22:09 +0300

On Wed, Aug 23, 2017 at 3:55 PM, L A Walsh <address@hidden> wrote:

>
>
> Greg Wooledge wrote:
>
>>
>>
>> They're not intended to work that way.  If you want to test f+x+s then
>> you just make another function:
>>
>> -fxs() { test -f "$1" && test -x "$1" && test -s "$1"; }
>>
>>
> How many different single-ops?  over 20?  That's 20 factorial
> combos.  You wanna include that in a script?  um...
>

You can use a loop, here is hack(ish) function that perhaps work (ie not
tested too much)

 testfile () {
    local OPTIND=1 f=${!#}
    while getopts abcdefghLkprsSuwxOGN opt;
          do
             case $opt in
               [abcdefghLkprsSuwxOGN]) test -$opt $f  || return 1;;
               *)return 1;;
             esac;
           done
 }

if testfile -fx file;then.


reply via email to

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