On Wed, 12 May 2010 22:57:47 David Korn wrote:
>
> Rewrite
> if [[ -n "$list" || ( $# -gt 1 && -t 0 && -t 1 ) ]]; then
>
> as
> ((list)) || ( (($# > 1 )) && [[ -t 0 || -t 1 ]] )
> or slightly more efficiently
> ((list)) || { (($# > 1)) && [[ -t 0 || -t 1 ]] ;}
>
But neither could be considered neat, clean or simpler to read than the
original. Generally my scripts never work hard enough to care about
microseconds of efficiency, so cleaner more readable code wins nearly
every time. Better efficiencies are to be had with algorithm or paying
attention to I/O in my kind of script.
> With ksh93u, (the first beta should be available before july 1st),
> you can define math functions. For example you could define the
> isatty math function with
> function .sh.math.isatty fd
> {
> .sh.value=0
> [[ -t $fd ]] && .sh.value=1
> }
>
> and then you could write this as
>
> (( list || ($#>0 && (isatty(0) || isatty(1))) ))
>
This is interesting. Do the functions always have to be in a .math.
namespace? Is (( )) locked into mathematical features? I see it already
supports a few dozen mathematical functions, some of which I've never
even heard of. I expect it would be a fairly easy win to add a bunch of
functions like stat() into the set which can be used by (( )).
I hesitate to suggest literal support for -X functionality but it's an
option. Perl has made it work, but I don't expect Perl is ever seen as a
shining beacon of language design...
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users