LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-19-2010, 03:29 PM   #1
vgoel
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Rep: Reputation: 0
ksh typeset bug?


The following bit of ksh script

Code:
STR='010'
typeset -i STR
echo $STR
produces '8' when run. When STR is set to '10' then it produces '10'. Is this as expected? Thanks.
 
Old 12-19-2010, 03:59 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
I don't know exactly how ksh handles it, but in bash, number strings beginning with zero are generally treated as octal values. The same thing is certainly happening here.
 
Old 12-19-2010, 06:16 PM   #3
vgoel
LQ Newbie
 
Registered: Dec 2010
Posts: 2

Original Poster
Rep: Reputation: 0
David thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
typeset tostay2003 Programming 2 08-07-2008 11:13 PM
ksh typeset problem sefaklc Programming 7 08-28-2007 11:37 PM
Typeset issues Asadullah Rathore Linux - General 1 09-24-2005 12:07 PM
typeset issues in ksh talalrabbani Linux - Distributions 0 09-23-2005 12:13 AM
typeset not working XST1 Programming 3 02-06-2005 11:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration