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: Chet Ramey
Subject: Re: extension of file-test primitives?
Date: Wed, 23 Aug 2017 09:37:51 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 8/23/17 9:34 AM, Greg Wooledge wrote:
> On Wed, Aug 23, 2017 at 04:22:09PM +0300, Pierre Gaston wrote:
>>  testfile () {
>>     local OPTIND=1 f=${!#}
>>     while getopts abcdefghLkprsSuwxOGN opt;
>>           do
>>              case $opt in
>>                [abcdefghLkprsSuwxOGN]) test -$opt $f  || return 1;;
> 
> "$f"
> 
>>                *)return 1;;
>>              esac;
>>            done
>>  }
>>
>> if testfile -fx file;then.
> 
> Add the quotes, make opt local too, and I think we have a winner.
This has the advantage of supporting both syntax options: a single
option with multiple operators or a series of options, each with one
or more operators, combined with a single operand.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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