LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Bedrock Linux
User Name
Password
Bedrock Linux This forum is for the discussion of Bedrock Linux.

Notices


Reply
  Search this Thread
Old 10-22-2019, 12:58 PM   #1
ychaouche
LQ Newbie
 
Registered: Mar 2017
Distribution: Mint, Debian, Q4OS, Mageia, KDE Neon
Posts: 26

Rep: Reputation: 1
Minor question about the code of the init script


In reading bedrock init's code, I found references to echo and cut, apparently to extract part of a string.

Code:
# Around line 364
complete_upgrade

init_timeout="$(cfg_values "init" "timeout")"
def_tuple="$(cfg_values "init" "default")"
def_stratum="$(deref "$(echo "${def_tuple}" | cut -d: -f1)")"
def_cmd="$(echo "${def_tuple}" | cut -d: -f2-)"
def_path=""
def_tuple should be of the form

Code:
void:/sbin/init
As described in the shipped /etc/bedrock.conf file

Code:
#
# Init to utilize by default if timeout expires.  Format is
#
#     default = <stratum>:<path>
#
# For example, to use void's /sbin/init, use:
#
#     default = void:/sbin/init
#
default =
If that's the case, then I propose to replace echo and cut with bash's % and # string operators, like so :

Code:
# Around line 364
complete_upgrade

init_timeout="$(cfg_values "init" "timeout")"
def_tuple="$(cfg_values "init" "default")"
def_stratum="$(deref ${def_tuple%:*}"
def_cmd="$(deref ${def_tuple#*:}"
def_path=""
Code:
ychaouche#ychaouche-PC 15:47:32 ~/MUSIQUE/CONTENT/BRASIL $ def_tuple=void:/sbin/init
ychaouche#ychaouche-PC 17:48:01 ~/MUSIQUE/CONTENT/BRASIL $ echo ${def_tuple%:*}
void
ychaouche#ychaouche-PC 17:48:06 ~/MUSIQUE/CONTENT/BRASIL $ echo ${def_tuple#*:}
/sbin/init
ychaouche#ychaouche-PC 17:48:11 ~/MUSIQUE/CONTENT/BRASIL $

Comments ?
 
Old 10-22-2019, 05:06 PM   #2
ParadigmComplex
Bedrock Linux Founder
 
Registered: Feb 2016
Distribution: Bedrock Linux
Posts: 123

Rep: Reputation: Disabled
This isn't running in bash, but the busybox sh we are using does provide that as well. That should work.

However, I don't want to make changes to working code that don't have discernible improvements, as all it does is introduce unnecessary risk without meaningful benefit. There's work towards a proper test suite infrastructure. Once that's in place with adequate tests to confirm such changes won't break something we can revisit the possibility.
 
  


Reply

Tags
bash scripting, strings


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] why init script cannot source init tools unless session root linuxecho Linux - Newbie 8 02-17-2014 06:17 PM
LXer: Radeon On Linux 3.8: Minor For Now, New Code Coming LXer Syndicated Linux News 0 12-08-2012 02:51 AM
What is the exact diff between init 1,init S and init s challavijay Linux - Newbie 1 08-05-2010 07:51 AM
Init script in /etc/init.d does not start at boot tdnnash25 Linux - Server 4 12-18-2009 05:40 PM
SED - minor changes work - Larger doesn't (working and non working code included) Nimoy Programming 17 09-22-2007 05:34 PM

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

All times are GMT -5. The time now is 07:53 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration