lkml.org 
[lkml]   [2020]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.4 165/312] scripts/config: allow colons in option strings for sed
    Date
    From: Jeremie Francois (on alpha) <jeremie.francois@gmail.com>

    [ Upstream commit e461bc9f9ab105637b86065d24b0b83f182d477c ]

    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: Jeremie Francois (on alpha) <jeremie.francois@gmail.com>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    scripts/config | 5 ++++-
    1 file changed, 4 insertions(+), 1 deletion(-)

    diff --git a/scripts/config b/scripts/config
    index 026aeb4f32ee3..73de17d396987 100755
    --- a/scripts/config
    +++ b/scripts/config
    @@ -6,6 +6,9 @@ myname=${0##*/}
    # If no prefix forced, use the default CONFIG_
    CONFIG_="${CONFIG_-CONFIG_}"

    +# We use an uncommon delimiter for sed substitutions
    +SED_DELIM=$(echo -en "\001")
    +
    usage() {
    cat >&2 <<EOL
    Manipulate options in a .config file from the command line.
    @@ -82,7 +85,7 @@ txt_subst() {
    local infile="$3"
    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
    mv "$tmpfile" "$infile"
    }
    --
    2.20.1


    \
     
     \ /
      Last update: 2020-05-08 15:19    [W:4.041 / U:0.172 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site