LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 12-15-2005, 09:56 AM   #1
kornelix
Member
 
Registered: Oct 2005
Location: Germany
Distribution: Ubuntu
Posts: 56

Rep: Reputation: 24
inconsistent bash behavior?


I need to parse a variable to get substrings. Some substrings are quoted to include imbedded blanks.

Please inspect the following:
Code:
[~] $ echo $record
aaa "bbb bbb" ccc
[~] $ set $record
[~] $ echo $2
"bbb
OK, so the quotes do not work.

So I tried the following:
Code:
[~] $ eval set $record
[~] $ echo $2
bbb bbb
It worked !!

Now I put this into a shell script, and it reverts to the unwanted behavior above, as though the "eval" were not there.

Is it bash or is it me? Can someone help?
 
Old 12-15-2005, 11:06 AM   #2
kornelix
Member
 
Registered: Oct 2005
Location: Germany
Distribution: Ubuntu
Posts: 56

Original Poster
Rep: Reputation: 24
My problem. The eval was working in the script, I was confused by an error made later in the script.

I do have a question, though. It does seem the first approach should work. Does someone have a logical explanation why it does not? Seems to me that bash is not self-consistent with its syntax.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Inconsistent permissions kosmonaft Linux - General 1 11-21-2005 11:21 PM
Mysterious bash behavior in scripts Woodsman Slackware 14 11-14-2005 04:29 PM
BASH script showing random behavior chatterbug89 Programming 12 07-19-2005 10:45 PM
strange sed/bash behavior mpdavig Programming 1 07-24-2004 02:27 AM
Strange, inconsistent BIND 9 behavior.... registering Linux - Networking 1 06-18-2004 04:12 PM


All times are GMT -5. The time now is 11:42 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration