ALT Linux Bugzilla
– Attachment 2456 Details for
Bug 14675
shell_config_set fails if value contains '/'
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
shell-config-fix
libshell-shell-config-fix.patch (text/plain), 1.52 KB, created by
Alexey Gladkov
on 2008-02-27 13:55:47 MSK
(
hide
)
Description:
shell-config-fix
Filename:
MIME Type:
Creator:
Alexey Gladkov
Created:
2008-02-27 13:55:47 MSK
Size:
1.52 KB
patch
obsolete
>diff --git a/libshell/shell-config b/libshell/shell-config >index dbe4567..e651a55 100644 >--- a/libshell/shell-config >+++ b/libshell/shell-config >@@ -8,6 +8,15 @@ __included_shell_config=1 > > __shell_config_comment='#' > >+__shell_config_quote_value() { >+ local out="$*" >+ if [ -z "${out##*[\\\\/]*}" ]; then >+ out="$(printf %s "$out" |sed -e 's/[\\\/]/\\&/g')" || >+ return 1 >+ fi >+ printf %s "$out" >+} >+ > shell_config_get() { > [ "$#" -ge 2 -a "$#" -le 3 ] || > fatal "Usage: shell_config_get file name [delim]" >@@ -23,7 +32,7 @@ shell_config_set() { > [ "$#" -ge 3 -a "$#" -le 5 ] || > fatal "Usage: shell_config_get file name value [read-delim [write-delim]]" > >- local n v created= >+ local n v nv= created= > > if [ ! -f "$1" ]; then > if [ ! -w "${1%/*}" ]; then >@@ -39,15 +48,18 @@ shell_config_set() { > n="$(quote_sed_regexp "$2")" > > if v="$(grep --mmap -m1 "^[[:space:]]*$n${4-=}" -- "$1" 2>/dev/null)"; then >- [ "${v#*$2${4-=}}" = "$3" ] || >- sed -i -e "s/^[[:space:]]*$n${4-=}.*/$2${5-=}$3/" -- "$1" >+ if [ "${v#*$2${4-=}}" != "$3" ]; then >+ nv="$(__shell_config_quote_value "$2${5-=}$3")" >+ sed -i -e "s/^[[:space:]]*$n${4-=}.*/$nv/" -- "$1" >+ fi > return > fi > > if [ -n "${__shell_config_comment-}" ] && > v="$(grep --mmap -m1 "^[[:space:]]*${__shell_config_comment:-#}[[:space:]]*$n${4-=}" -- "$1" 2>/dev/null)"; then > v="$(quote_sed_regexp "$v")" >- sed -i -e "s/^$v\$/$2${5-=}$3/" -- "$1" >+ nv="$(__shell_config_quote_value "$2${5-=}$3")" >+ sed -i -e "s/^$v\$/$nv/" -- "$1" > return > fi > fi
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 14675
: 2456