Commit e461bc9f authored by Jeremie Francois (on alpha)'s avatar Jeremie Francois (on alpha) Committed by Masahiro Yamada

scripts/config: allow colons in option strings for sed

Sed broke on some strings as it used colon as a separator.
I made it more robust by using \001, which is legit POSIX AFAIK.

E.g. ./config --set-str CONFIG_USBNET_DEVADDR "de:ad:be:ef:00:01"
failed with: sed: -e expression #1, char 55: unknown option to `s'
Signed-off-by: default avatarJeremie Francois (on alpha) <jeremie.francois@gmail.com>
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent ae83d0b4
...@@ -7,6 +7,9 @@ myname=${0##*/} ...@@ -7,6 +7,9 @@ myname=${0##*/}
# If no prefix forced, use the default CONFIG_ # If no prefix forced, use the default CONFIG_
CONFIG_="${CONFIG_-CONFIG_}" CONFIG_="${CONFIG_-CONFIG_}"
# We use an uncommon delimiter for sed substitutions
SED_DELIM=$(echo -en "\001")
usage() { usage() {
cat >&2 <<EOL cat >&2 <<EOL
Manipulate options in a .config file from the command line. Manipulate options in a .config file from the command line.
...@@ -83,7 +86,7 @@ txt_subst() { ...@@ -83,7 +86,7 @@ txt_subst() {
local infile="$3" local infile="$3"
local tmpfile="$infile.swp" local tmpfile="$infile.swp"
sed -e "s:$before:$after:" "$infile" >"$tmpfile" sed -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmpfile"
# replace original file with the edited one # replace original file with the edited one
mv "$tmpfile" "$infile" mv "$tmpfile" "$infile"
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment