开发者

"unnecessary string to number conversion" in ksh script

开发者 https://www.devze.com 2023-01-26 11:53 出处:网络
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 co开发者_StackOverflow中文版nversion\". My code i

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 co开发者_StackOverflow中文版nversion". 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.


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 ))
0

精彩评论

暂无评论...
验证码 换一张
取 消