Commit edcc1437 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm repo enable/disable: use sed_escape()

parent 2daba332
...@@ -22,10 +22,6 @@ load_helper epm-sh-altlinux ...@@ -22,10 +22,6 @@ load_helper epm-sh-altlinux
alt_LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list' alt_LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list'
sed_quote()
{
echo "$*" | sed -e 's|\(\[\)|\\\1|g' -e 's|\(\]\)|\\\1|g' -e 's|\(\.\)|\\\1|g'
}
__epm_repodisable_alt() __epm_repodisable_alt()
{ {
...@@ -34,12 +30,12 @@ __epm_repodisable_alt() ...@@ -34,12 +30,12 @@ __epm_repodisable_alt()
if rhas "$1" "\^rpm" ; then if rhas "$1" "\^rpm" ; then
rl="$(echo "$1" | sed -e 's|\^||')" rl="$(echo "$1" | sed -e 's|\^||')"
else else
rl="$( (epm --quiet repolist) 2>/dev/null | grep -E "$(sed_quote "$1")")" rl="$( (epm --quiet repolist) 2>/dev/null | grep -F "$1" | head -n1 )"
[ -z "$rl" ] && warning "Can't find '$1' entries in the repos (see '# epm repolist' output)" && return 1 [ -z "$rl" ] && warning "Can't find '$1' entries in the repos (see '# epm repolist' output)" && return 1
fi fi
echo "$rl" | while read rp ; do echo "$rl" | while read rp ; do
[ -n "$dryrun" ] && echo "will comment $rp" && continue [ -n "$dryrun" ] && echo "will comment $rp" && continue
sed -i -e "s|^\($(sed_quote "$rl")\)|#\1|" $alt_LISTS sed -i -e "s|^\($(sed_escape "$rl")\)|#\1|" $alt_LISTS
done done
} }
......
...@@ -22,10 +22,6 @@ load_helper epm-sh-altlinux ...@@ -22,10 +22,6 @@ load_helper epm-sh-altlinux
alt_LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list' alt_LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list'
sed_quote()
{
echo "$*" | sed -e 's|\(\[\)|\\\1|g' -e 's|\(\]\)|\\\1|g' -e 's|\(\.\)|\\\1|g'
}
__epm_repoenable_alt() __epm_repoenable_alt()
{ {
...@@ -34,12 +30,12 @@ __epm_repoenable_alt() ...@@ -34,12 +30,12 @@ __epm_repoenable_alt()
if rhas "$1" "\^rpm" ; then if rhas "$1" "\^rpm" ; then
rl="$(echo "$1" | sed -e 's|\^||')" rl="$(echo "$1" | sed -e 's|\^||')"
else else
rl="$( (epm --quiet --all repolist) 2>/dev/null | grep -E "$(sed_quote "$1")")" rl="$( epm --quiet --all repolist 2>/dev/null | grep -F "$1" | head -n1 | sed -e 's|[[:space:]]*#[[:space:]]*||' )"
[ -z "$rl" ] && warning "Can't find commented '$1' in the repos (see '# epm repolist' output)" && return 1 [ -z "$rl" ] && warning "Can't find commented '$1' in the repos (see '# epm repolist' output)" && return 1
fi fi
echo "$rl" | while read rp ; do echo "$rl" | while read rp ; do
[ -n "$dryrun" ] && echo "will uncomment $rp" && continue [ -n "$dryrun" ] && echo "will uncomment $rp" && continue
sed -i -e "s|^[[:space:]]*#[[:space:]]*\($(sed_quote "$rl")\)|\1|" $alt_LISTS sed -i -e "s|^[[:space:]]*#[[:space:]]*\($(sed_escape "$rl")\)|\1|" $alt_LISTS
done done
} }
......
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