On Wed, 12 May 2010 14:19:22 Mario DeFazio wrote:
> (( )) is purely for arithmetic expressions.
> I think the simplest, most readable valid "upgrade"
> to your original expression is
> 
>          if (( $# > 1 )) && [[ -t 0 && -t 1 ]]; then
> 
> Anyway, that's how I would do it. :-)
> 

Ok, that's what I was thinking. My original expression was a bit more 
complex than this:

    if [[ -n "$list" || ( $# -gt 1 && -t 0 && -t 1 ) ]]; then

Where list can be '' or 1

the -n "$list" can be substituted with ((list)) as long as the unset 
value of $list is set to 0 - but then the expression maps to:

    if (( $# > 1 )) && [[ -t 0 && -t 1 ]] || ((list)); then

which could hardly be called a simplification. I was hoping for 
something like

    if (( list || $# > 1 && -t 0 && -t 1 )); then

which is neater and presumably better by some abstract measure.
I can see how -t would violate the C-like syntax of arithmetic 
expressions, but surely something can be used? a simple stat() function 
perhaps?

It seems like there might be scope for handling at least the -X 
operators in some form, and perhaps other traditional operators. 
Restricting (( )) to pure maths seems to violate the spirit of shell 
scripting which should make it trivial to work with files, directories 
and other regular "job-control" features.


_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to