Operating System - HP-UX
1846539 Members
2366 Online
110256 Solutions
New Discussion

question..about parameter

 
SOLVED
Go to solution
navin
Super Advisor

question..about parameter

if [[ "$PRO_NAME" == "" || "$DIVISION_NAME" == "" ]]; then
The above line is from one of my script - i get the below error
syntax error at line 17 : `==' unexpected

In HP is "==" is not the right operand
pls advice
Thanks
Learning ...
3 REPLIES 3
Patrick Wallek
Honored Contributor
Solution

Re: question..about parameter

Just use one '='

if [[ "${PRO_NAME}" = "" || "${DIVISION_NAME}" = "" ]]; then
James R. Ferguson
Acclaimed Contributor

Re: question..about parameter

Hi Havin:

In the Shell, string equality is simply "=". Non-equality for a string is "!=".

Unfortunately this means in a shell script that the "=" operator is either string equality or an lvalue assignment. Silly, isn't it?

See the 'test(1)' manpages.

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: question..about parameter

> In HP is "==" is not the right operand

Actually, this has nothing to do with HP-UX. It is a shell operator and whether it works is completely dependent on the shell (ksh-88, ksh-93, POSIX shell, etc) you are using. HP-UX supplies 5 major shells:

/usr/bin/sh - the POSIX shell, a superset of ksh-88
/usr/bin/ksh - Korn shell 1988
/usr/dt/bin/dtksh - Korn shell 1993
/usr/old/bin/sh - the (old) Bourne shell
/usr/bin/csh - C shell

And of course, you can add other shells like bash, tcsh, etc. So the question is: what sheel did you specify on line #1 of your script? If nothing was specified, you will get random results. Line #1 should look like this:

#!/usr/bin/sh

or for multi-system compatibility, use /bin as in:

#!/bin/ksh

In your example, the test will run perfectly with this line #1:

#!/usr/dt/bin/dtksh

which specifies Korn shell 1993, a more modern and enhanced version of the Korn shell. The == operator replaces = in ksh-93.
so like grave accents (deprecated in favor of $(...) in POSIX and ksh), now the = sign is deprecated in favor of == for ksh 1993.


Bill Hassell, sysadmin