LinuxQuestions.org
Visit Jeremy's Blog.
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 10-18-2006, 05:09 AM   #1
noir911
Member
 
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
bash varible define query


I noticed that there's no difference in defining varibales without double-quotations (")

Code:
VARIABLE=/path/to/file

VARIABLE="/path/to/file"
I was wondering why bash doesn't give any warning or error if I define variables witout the quotes? What difference does it make?

Last edited by noir911; 10-18-2006 at 05:31 AM.
 
Old 10-18-2006, 05:28 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
it certainly should complain. if you run your first example there then bash will interpret the word "is" as the command you wish to run, and run it... and fail... the second example doesn't need quotes, but the first certainly would do.
 
Old 10-18-2006, 05:33 AM   #3
noir911
Member
 
Registered: Apr 2004
Posts: 682

Original Poster
Rep: Reputation: Disabled
Sorry about the confusion but there is no "is" here.

I meant to say the different between

Code:
VARIABLE=/path/to/file

VARIABLE="/path/to/file"
 
Old 10-18-2006, 05:54 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
ahh well there you go... the whitespace is what requires the "'s... so you've answered yourself really.
 
Old 10-18-2006, 01:39 PM   #5
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Rep: Reputation: 30
...............................................

Last edited by ygloo; 10-18-2006 at 02:25 PM.
 
  


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
Varible substitution in Bash script RonV Linux - Newbie 2 06-04-2006 12:11 PM
redirect stdout to a varible Furlinastis Programming 3 12-07-2005 06:01 AM
how to export a varible in the kernel firefoxii Programming 0 06-08-2004 04:06 AM
command output to varible!!! fooforon Programming 3 02-05-2004 08:41 PM
define start-bash for user... pablovschby Linux - Software 16 11-13-2003 02:52 PM

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

All times are GMT -5. The time now is 05:48 AM.

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