* [PATCH] scripts/config: allow colons in option strings for sed
@ 2020-04-10 16:57 Jeremie Francois (on alpha)
2020-04-10 17:36 ` Randy Dunlap
2020-04-12 19:23 ` Masahiro Yamada
0 siblings, 2 replies; 3+ messages in thread
From: Jeremie Francois (on alpha) @ 2020-04-10 16:57 UTC (permalink / raw)
Cc: Jeremie Francois (on alpha), linux-kernel
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>
---
scripts/config | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/scripts/config b/scripts/config
index e0e39826dae9..d365081b60b2 100755
--- a/scripts/config
+++ b/scripts/config
@@ -7,6 +7,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.
@@ -83,7 +86,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.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scripts/config: allow colons in option strings for sed
2020-04-10 16:57 [PATCH] scripts/config: allow colons in option strings for sed Jeremie Francois (on alpha)
@ 2020-04-10 17:36 ` Randy Dunlap
2020-04-12 19:23 ` Masahiro Yamada
1 sibling, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2020-04-10 17:36 UTC (permalink / raw)
To: Jeremie Francois (on alpha), LKML; +Cc: linux-kbuild, Masahiro Yamada
[adding Cc's]
On 4/10/20 9:57 AM, Jeremie Francois (on alpha) wrote:
> 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>
> ---
> scripts/config | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/config b/scripts/config
> index e0e39826dae9..d365081b60b2 100755
> --- a/scripts/config
> +++ b/scripts/config
> @@ -7,6 +7,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.
> @@ -83,7 +86,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"
> }
>
--
~Randy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scripts/config: allow colons in option strings for sed
2020-04-10 16:57 [PATCH] scripts/config: allow colons in option strings for sed Jeremie Francois (on alpha)
2020-04-10 17:36 ` Randy Dunlap
@ 2020-04-12 19:23 ` Masahiro Yamada
1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2020-04-12 19:23 UTC (permalink / raw)
To: Jeremie Francois (on alpha); +Cc: Linux Kernel Mailing List
On Sat, Apr 11, 2020 at 1:58 AM Jeremie Francois (on alpha)
<jeremie.francois@gmail.com> wrote:
>
> 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>
> ---
> scripts/config | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/config b/scripts/config
> index e0e39826dae9..d365081b60b2 100755
> --- a/scripts/config
> +++ b/scripts/config
> @@ -7,6 +7,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")
At first, 'echo -en' caught my eye,
but this script is always run by bash.
So, there is no portability issue here.
Applied to linux-kbuild.
Thanks.
> +
> usage() {
> cat >&2 <<EOL
> Manipulate options in a .config file from the command line.
> @@ -83,7 +86,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.17.1
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-12 19:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10 16:57 [PATCH] scripts/config: allow colons in option strings for sed Jeremie Francois (on alpha)
2020-04-10 17:36 ` Randy Dunlap
2020-04-12 19:23 ` Masahiro Yamada
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.