Article 4T0PN Minor question about the code of the init script

Minor question about the code of the init script

by
ychaouche
from LinuxQuestions.org on (#4T0PN)
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/initAs 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 ?latest?d=yIl2AUoC8zA latest?i=jdjULhyQsOo:xw_6VnZiyFA:F7zBnMy latest?i=jdjULhyQsOo:xw_6VnZiyFA:V_sGLiP latest?d=qj6IDK7rITs latest?i=jdjULhyQsOo:xw_6VnZiyFA:gIN9vFwjdjULhyQsOo
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments