LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Games
User Name
Password
Linux - Games This forum is for all discussion relating to gaming in Linux.

Notices


Reply
  Search this Thread
Old 10-18-2010, 07:38 AM   #1
Abid Malik
LQ Newbie
 
Registered: Sep 2010
Posts: 25

Rep: Reputation: -1
Question read number form function


Hello Everyone!

i have the following code:


#!/bin/bash

function get
{
read $1
if [ ! -n "$1" ]
then
$1=0
fi

}

get n
get m

echo n = $n
echo m = $m


now if we just press enter key at read instance. it should assign a zero value. But this code is not assigning an integer value to $1 but a string.
 
Old 10-18-2010, 09:18 AM   #2
merijnofiets
LQ Newbie
 
Registered: Sep 2010
Location: Amsterdam
Distribution: Arch linux
Posts: 11

Rep: Reputation: 0
"Data types are not declared for bash script"

so a string and an integer can be the same, if the string contains a number.
what is the string containing btw?
 
  


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
silo read error on block <number>... results in a short read peterlowrie Linux - Hardware 0 02-07-2010 07:39 PM
can't read from the device driver using read() function. parthi_s Linux - Newbie 1 03-23-2009 06:16 AM
understanding gdb output of a C function in disassembled form. koodoo Programming 7 04-12-2006 10:55 AM
PHP: html Form Select function problem camlinux Programming 2 05-15-2005 08:23 PM
Calculation of number of bytes submitted with form blampain Linux - Networking 6 03-30-2004 05:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Games

All times are GMT -5. The time now is 12:02 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