LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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


Closed Thread
  Search this Thread
Old 10-29-2021, 12:20 AM   #1
Faki
Member
 
Registered: Oct 2021
Posts: 574

Rep: Reputation: Disabled
Difference between `eval set -- "$opts"` and the direct call `set -- "$opts"`


What is the difference between

eval set -- "$opts"

and a direct call using

set -- "$opts"

Have seen `eval set -- "$opts"` being used quite frequently with `getopt`.
 
Old 10-29-2021, 01:50 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
eval will evaluate the content of that variable ($opts) before executing set. That means also a single string will be split into parts.

I see it is just a duplicate of https://www.linuxquestions.org/quest...al-4175702722/
 
Old 10-29-2021, 02:01 AM   #3
Faki
Member
 
Registered: Oct 2021
Posts: 574

Original Poster
Rep: Reputation: Disabled
I cannot see an adequate response about the question of using one or the other. Examples showing how one behaves differently than the other would be beneficial.
 
Old 10-29-2021, 02:04 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
the same people will answer here and there. There is no reason to duplicate a thread. Otherwise I think the answer is there, just you need to learn bash. This is not the easiest part of the shell.
 
  


Closed Thread

Tags
bash, eval, set



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
[SOLVED] Difference between eval set ... and set `...` (backticks) pinkzomo Programming 10 04-30-2016 03:55 AM
difference between eval set ... and set `` pinkzomo Programming 1 04-26-2016 09:28 AM
What is the difference between Eval and OSS usaf_sp SUSE / openSUSE 4 10-16-2005 10:51 PM
config.opts and/or wireless.opts for RH7.3 using LinkSys (orinoco_cs) to Apple AirPor zeus_sd Linux - Laptop and Netbook 4 08-04-2003 11:35 PM

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

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