Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


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

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:
[~] $ echo $record
aaa "bbb bbb" ccc
[~] $ set $record
[~] $ echo $2
OK, so the quotes do not work.

So I tried the following:
[~] $ 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
Registered: Oct 2005
Location: Germany
Distribution: Ubuntu
Posts: 57

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.


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 > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:33 AM.

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