The only way is testing it on an AIX machine. Do you have access yourself to an AIX machine so you can test this simple thing?
Code:
cont=1
if [ cont -eq 1 ]
then
echo "It works"
fi
I was asked to take a look at this and comment on what the standards say about this ksh behavior. The standards leave unspecified what happens if both operands of the test -eq, -ne, -lt, -le, -gt, and -ge binary primaries are not integer operands.
The standards allow, but do not require the test expression and [ expression ] utilities to be implemented as shell built-ins (as they are in bash and ksh)). If test and [ ... ] aren't implemented as shell built-ins, there is no way that the behavior shown here would be possible. In ksh (at least ksh on AIX and on OS X), if a variable name is given where a number is needed in these cases, the value of the variable is substituted into the expression even when the $ is not present.
The standards specify this behavior for arithmetic expansions. That is, the sequences:
Code:
n=0
while [ $n -lt 5 ]
do printf "%d\n" $(($n++))
done
and:
Code:
n=0
while [ $n -lt 5 ]
do printf "%d\n" $((n++))
done
are required to do the same thing. So, it seems like a logical extension to me to not require the $ in the expression in these test exp ([ exp ]) expressions either.
Obviously, this need not be portable to other shells and might not even be portable to other versions of ksh.
Last edited by Don Cragun; 06-24-2014 at 03:04 AM..
Reason: Add note about portability.
These 3 Users Gave Thanks to Don Cragun For This Post:
hi all
i m working in a company ...and i have to migrate a C application running on SCO-UNIX to Red hat linux.
can anybody tell me what is the difference between C commands and shell scripting on SCO-UNIX and LINUX.
best regards
harsh (3 Replies)
I am trying to set some environment variables in a shell script which is written in Kshell. I am invoking this script in .profile. The problem is envirnment variables are set within the script but after exiting the script those are gone. I don't have any problem with If I have Kshell as my default... (0 Replies)
Dear All,
What points should i keep in mind while migrating scripts from HP-UX to AIX.
Are there any notes available for this?
cheers,
vishal (1 Reply)
Hi All,
I am currently facing new problem of migrating C(c language) application from AIX machine to Linux machine. We are using GCC to compile the source code..
But facing with the compilation issues, with lot of GCC C libs differing between AIX box to Linux box...
Pls help me... (1 Reply)
Hi All,
I am currently facing new problem of migrating C(c language) application from AIX machine to Linux machine. We are using GCC to compile the source code..
But facing with the compilation issues, with lot of GCC C libs differing between AIX box to Linux box...
Pls help me... (1 Reply)
We are changing our OS from HP-Unix 11 to Linux Red Hat. We have few k- shell, c - shell and sql scripts which are currently running under HP-Unix 11. Will these scripts work on LINUX as it is? or we need to do any code changes?IS there anyone who have done this kind of migration before?Thanks for... (2 Replies)
We have certain number of scripts that run on AIX server using ksh.
Now that we migrate these scripts to Linux servers.
We need to know what are the changes that we have to perform in script to make it compatible to run on Linux.
Say like in our Unix -AIX "print" command worked.
But that did... (6 Replies)
I'm New to AIX / VIOS
We're doing a FC switch cutover on an ibm device, connected via SAN.
How do I tell if one path to my remote disk is lost? (aix lvm)
How do I tell when my link is down on my HBA port?
Appreciate your help, very much! (4 Replies)
Hi,
recently we have migrated our current AIX server to Linux, we have lot of shell script, few of them are FTP scripts.
we have copied the complete AIX file system to linux 7.2 as it is.
could you please highlight what are the things we need to look into it .
in AIX we are using .netrc to... (3 Replies)