docs(iso): Explain sed insert_n_at_the_end mechanism (#6)
This commit is contained in:
parent
79feaed5ac
commit
e3025883fa
15
setup.sh
15
setup.sh
@ -501,6 +501,21 @@ function in_file_in_array_insert_n_at_the_end () {
|
|||||||
arg_file="${1:?}"
|
arg_file="${1:?}"
|
||||||
arg_array="${2:?}"
|
arg_array="${2:?}"
|
||||||
arg_string="${3:?}"
|
arg_string="${3:?}"
|
||||||
|
|
||||||
|
# Look for end of array, insert "${arg_string}" right before
|
||||||
|
#
|
||||||
|
# For following example text we're assuming that:
|
||||||
|
# - "${arg_array}" equals 'HOOKS'
|
||||||
|
# - "${arg_string}" equals 'net'
|
||||||
|
#
|
||||||
|
# This:
|
||||||
|
# - Finds a 'HOOKS=' array definition, saves it as \1
|
||||||
|
# - Finds as many non-closing parenthesis characters as possible, so all
|
||||||
|
# characters until just before the final ')' character of the line and
|
||||||
|
# saves this as \2
|
||||||
|
# - Finds the closing parenthesis character plus all non-line break
|
||||||
|
# characters until end of line that come after it and saves this as \3
|
||||||
|
# - Adds a space character and 'net' after \2
|
||||||
sed -ri \
|
sed -ri \
|
||||||
-e 's'$'\x1''('"${arg_array}"'=)([^)]*)(\)[^\r\n\f]*)'$'\x1''\1\2 '"${arg_string}"'\3'$'\x1''g' \
|
-e 's'$'\x1''('"${arg_array}"'=)([^)]*)(\)[^\r\n\f]*)'$'\x1''\1\2 '"${arg_string}"'\3'$'\x1''g' \
|
||||||
"${arg_file}"
|
"${arg_file}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user