me_and
me_and

Reputation: 15664

"unnecessary string to number conversion" in ksh script

I'm doing some scripting in the Korn shell, and I can't work out how to avoid the warning "variable expansion requires unnecessary string to number conversion". My code is as follows:

#!/bin/ksh
testnum=04
(( $testnum == 4 ))

The error's being spotted on that third line. I've tried adding integer testnum, but that appears to make no difference.

Upvotes: 0

Views: 2266

Answers (1)

jlliagre
jlliagre

Reputation: 30843

I suspect this message to mean you are converting testnum to a string by using $testnum in the numerical part of your script which is unnecessary. You probably won't have this message when using this syntax:

#!/bin/ksh
testnum=04
(( testnum == 4 ))

Upvotes: 2

Related Questions