docs(iso): Explain sed in_array_remove_n mechanism (#6)
This commit is contained in:
parent
e3025883fa
commit
1181432add
17
setup.sh
17
setup.sh
@ -526,6 +526,23 @@ function in_file_in_array_remove_n () {
|
||||
arg_file="${1:?}"
|
||||
arg_array="${2:?}"
|
||||
arg_string="${3:?}"
|
||||
|
||||
# Look for any line that contains "${arg_string}", delete that string
|
||||
#
|
||||
# For following example text we're assuming that:
|
||||
# - "${arg_array}" equals 'HOOKS'
|
||||
# - "${arg_string}" equals 'fsck'
|
||||
#
|
||||
# First -e expression removes 'fsck' wherever it is defined as the one
|
||||
# and only element of any HOOKS=(fsck) should such a line exist.
|
||||
#
|
||||
# Second -e expression finds string 'fsck' where it's preceded by space
|
||||
# character(s) and followed by either space character(s) or a closing
|
||||
# parenthesis.
|
||||
#
|
||||
# Third -e expression finds string 'fsck' where it's preceded by space
|
||||
# character(s) or an opening parenthesis and followed space
|
||||
# character(s).
|
||||
sed -ri \
|
||||
-e 's'$'\x1''((\()('"${arg_string}"')(\)))'$'\x1''\2\4'$'\x1''g' \
|
||||
-e 's'$'\x1''('"${arg_array}"'=.*?)([[:space:]]+'"${arg_string}"')([[:space:]]+|\))'$'\x1''\1\3'$'\x1''g' \
|
||||
|
Loading…
x
Reference in New Issue
Block a user