cc: [EMAIL PROTECTED]
Subject: Re: [ast-users] Ksh 93 s+ Issue?
--------
> Hello AST users,
>
> I have the following test script (see below). The last line commented
> runs fine on ksh88 (solaris) and pdksh (rehat linux). When trying to
> run the script on Version M 1993-12-28 s+ redhat linux I get line 15:
> syntax error at line 17: `&&' unexpected. Could this be a bug?
>
>
> #!/bin/ksh
> ENV_DEBUGON=YES
> [ "$ENV_DEBUGON" == "YES" ] && set -x
>
> cat<<%END%>/tmp/junk
> abc
> %END%
>
> FILE=/tmp/junk
> [ -s $FILE ] && [ `wc -l $FILE | nawk '{print $1}'` -gt 2 ] && [ mv
> $FILE /tmp/junkf ]
> #[ -s $FILE ] && (( `wc -l $FILE | nawk '{print $1}'` > 2 )) && [ mv
> $FILE /tmp/junkf ]
>
>
>
This is a bug in the lexer but too late to fix for ksh93s+.
I would recommend changing
[ -s $FILE ] && (( `wc -l $FILE | nawk '{print $1}'` > 2 )) && [ mv $FILE
/tmp/junkf ]
to
[ -s $FILE ] && (( $(wc -l $FILE | nawk '{print $1}') > 2 )) && [ mv $FILE
/tmp/junkf ]
since `` is obsolete in ksh93 anyway.
However, this can be written more efficiently as
[ -s $FILE ] && (( $(wc -l < $FILE) > 2 )) && [ mv $FILE /tmp/junkf ]
since it doesn't require nawk or the pipeline.
David Korn
[EMAIL PROTECTED]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users