LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-30-2022, 09:54 AM   #1
Daedra
Senior Member
 
Registered: Dec 2005
Location: Springfield, MO
Distribution: Slackware64-15.0
Posts: 2,730

Rep: Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393
running a string as a command as it pertains to mkinitrd_command_generator.sh


I have a script I wrote that updates my kernels for all my machines whether they be bare metal, virtual, 32bit or 64bit. I am making some tweaks to it. I can run the the output mkinitrd_command_generator.sh as a command two different ways

using eval
Code:
eval $(sh /usr/share/mkinitrd/mkinitrd_command_generator.sh -r)
or pipe it to bash
Code:
sh /usr/share/mkinitrd/mkinitrd_command_generator.sh -r | bash
My questions is, does it matter which way I do it or are both acceptable ways in your guys opinion?

Thanks.
 
Old 01-30-2022, 11:21 AM   #2
luvr
Member
 
Registered: May 2005
Location: Boom - The Home Town of Tomorrowland, Belgium
Distribution: Slackware, Xubuntu
Posts: 459
Blog Entries: 2

Rep: Reputation: 194Reputation: 194
Quote:
Originally Posted by Daedra View Post
using eval
Code:
eval $(sh /usr/share/mkinitrd/mkinitrd_command_generator.sh -r)
If I remember correctly, you don't even need the "eval".
Cannot check at the moment, but just
Code:
$(/usr/share/mkinitrd/mkinitrd_command_generator.sh -r)
should suffice, I believe.
 
Old 01-30-2022, 12:38 PM   #3
Daedra
Senior Member
 
Registered: Dec 2005
Location: Springfield, MO
Distribution: Slackware64-15.0
Posts: 2,730

Original Poster
Rep: Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393
Yes you are correct, that also works. I am mostly just wondering if there is a generally accepted "best practice" or if it doesn't matter.
 
Old 01-30-2022, 12:51 PM   #4
kaott
Member
 
Registered: Mar 2020
Posts: 63

Rep: Reputation: Disabled
I think the only real difference in this case is avoiding a subshell or not (and the quirks that come with subshells, e.g. setting a variable in a subshell isn't reflected in parent shell). Eval has the usual security concerns of passing unsanitized inputs to it, but in this case either should be fine.
 
1 members found this post helpful.
Old 01-30-2022, 01:23 PM   #5
luvr
Member
 
Registered: May 2005
Location: Boom - The Home Town of Tomorrowland, Belgium
Distribution: Slackware, Xubuntu
Posts: 459
Blog Entries: 2

Rep: Reputation: 194Reputation: 194
Quote:
Originally Posted by Daedra View Post
I am mostly just wondering if there is a generally accepted "best practice" or if it doesn't matter.
No idea if there's a "generally accepted" answer, but my personal preference goes to the simplest solution. When I develop a script, I sometimes arrive at a solution that, while it does work, later on turns out to be far more complicated than it needs to be. To me, then, the simpler solution usually looks like the more elegant one, as well, and I tend to prefer it.
 
Old 01-30-2022, 02:41 PM   #6
fourtysixandtwo
Member
 
Registered: Jun 2021
Location: Alberta
Distribution: Slackware...mostly
Posts: 328

Rep: Reputation: 217Reputation: 217Reputation: 217
Not the answer you are asking for, but another solution is to just use the -c option and pipe it to /etc/mkinitrd.conf on the initial install once. Then you just need to run "mkinitrd -F -k $kernel_version" from then on.

Any particular reason you need to generate it fresh every time?
 
2 members found this post helpful.
Old 01-30-2022, 03:03 PM   #7
Daedra
Senior Member
 
Registered: Dec 2005
Location: Springfield, MO
Distribution: Slackware64-15.0
Posts: 2,730

Original Poster
Rep: Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393
Quote:
Originally Posted by fourtysixandtwo View Post
Not the answer you are asking for, but another solution is to just use the -c option and pipe it to /etc/mkinitrd.conf on the initial install once. Then you just need to run "mkinitrd -F -k $kernel_version" from then on.

Any particular reason you need to generate it fresh every time?
I use mkinitrd.conf on all my main machines, the mkinitrd_command_generator.sh is for throw away vm's.
 
Old 01-30-2022, 03:19 PM   #8
fourtysixandtwo
Member
 
Registered: Jun 2021
Location: Alberta
Distribution: Slackware...mostly
Posts: 328

Rep: Reputation: 217Reputation: 217Reputation: 217
Quote:
Originally Posted by Daedra View Post
I use mkinitrd.conf on all my main machines, the mkinitrd_command_generator.sh is for throw away vm's.
Cool, I'll just shut up then!
 
Old 01-30-2022, 03:47 PM   #9
Daedra
Senior Member
 
Registered: Dec 2005
Location: Springfield, MO
Distribution: Slackware64-15.0
Posts: 2,730

Original Poster
Rep: Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393Reputation: 1393
Quote:
Originally Posted by fourtysixandtwo View Post
Cool, I'll just shut up then!
Not at all, TBH honest I had forgot about it and I could change the script to do that. My script already checks for a minitrd.conf first and if it doesn't find it then it uses mkinitrd_command_generator.sh. It does make sense to create one but with throw away VM's mkinitrd_command_generator.sh is good enough.

Last edited by Daedra; 01-30-2022 at 03:56 PM.
 
1 members found this post helpful.
  


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
mkinitrd_command_generator.sh: broken with 3.17.3 kernel lems Slackware 5 11-17-2014 01:24 PM
mkinitrd_command_generator and ehci_hcd pdi Slackware 3 11-07-2014 11:14 AM
mkinitrd_command_generator.sh doesn't recognize kernel file ...? chexmix Slackware 13 06-17-2013 06:08 AM
Boot error message (mkinitrd_command_generator.sh) samac Slackware 12 03-05-2010 01:27 PM
Core 2 Quad Q6600 + openSUSE 10.3 (subject pertains programming) Tegramon Programming 5 02-20-2008 06:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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