sed usage portability fixes: avoid \+
This commit is contained in:
parent
a17b2dbc73
commit
4790b1a0c6
1
CHANGES
1
CHANGES
@ -37,6 +37,7 @@ bash-completion (2.x)
|
||||
input in external command arguments (Debian: 552631).
|
||||
* Add /sbin to $PATH when invoking ifconfig and iwconfig.
|
||||
* Combine dcop and qdbus completions into the latter.
|
||||
* sed usage portability fixes.
|
||||
|
||||
[ Freddy Vulto ]
|
||||
* Added _get_pword() helper function, thanks to Sung Pae (Alioth: #312030)
|
||||
|
@ -480,7 +480,7 @@ _configured_interfaces()
|
||||
{
|
||||
if [ -f /etc/debian_version ]; then
|
||||
# Debian system
|
||||
COMPREPLY=( $( compgen -W "$( sed -ne 's|^iface \([^ ]\+\).*$|\1|p' \
|
||||
COMPREPLY=( $( compgen -W "$( sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p'\
|
||||
/etc/network/interfaces )" -- "$cur" ) )
|
||||
elif [ -f /etc/SuSE-release ]; then
|
||||
# SuSE system
|
||||
@ -1312,7 +1312,7 @@ _known_hosts_real()
|
||||
fi
|
||||
# append any available aliases from config files
|
||||
if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
|
||||
local host_aliases=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^#*?]*\)\(#.*\)\?$/\2/p' "${config[@]}" )
|
||||
local host_aliases=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\?$/\2/p' "${config[@]}" )
|
||||
hosts=$( compgen -W "$host_aliases" -- "$cur" )
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $hosts )
|
||||
fi
|
||||
@ -1526,7 +1526,7 @@ _longopt()
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | sed -e '/--/!d' \
|
||||
-e 's/.*\(--[-A-Za-z0-9]\+\).*/\1/' |sort -u )"\
|
||||
-e 's/.*\(--[-A-Za-z0-9]\{1,\}\).*/\1/' | sort -u )" \
|
||||
-- "$cur" ) )
|
||||
elif [[ "$1" == rmdir ]]; then
|
||||
_filedir -d
|
||||
|
@ -22,7 +22,7 @@ _yum_repolist()
|
||||
# http://yum.baseurl.org/ticket/83
|
||||
# Drop first ("repo id repo name") and last ("repolist: ...") rows
|
||||
yum --noplugins -C repolist $1 2>/dev/null | \
|
||||
sed -ne '/^repo\(\s\+id\|list:\)/d' -e 's/[[:space:]].*//p'
|
||||
sed -ne '/^repo\(\s\s*id\|list:\)/d' -e 's/[[:space:]].*//p'
|
||||
}
|
||||
|
||||
_yum_plugins()
|
||||
|
@ -20,7 +20,8 @@ _gdb()
|
||||
# functions and aliases. Thus we need to retrieve the program
|
||||
# names manually.
|
||||
IFS=":"
|
||||
local path_array=( $(echo "$PATH" | sed 's/::\+/:/g;s/^:\|:$//g') )
|
||||
local path_array=( $( echo "$PATH" | \
|
||||
sed 's/:\{2,\}/:/g;s/^:\|:$//g' ) )
|
||||
IFS=$'\n'
|
||||
COMPREPLY=( $( compgen -d -W '$(find "${path_array[@]}" . \
|
||||
-mindepth 1 -maxdepth 1 -not -type d -executable \
|
||||
|
@ -8,7 +8,7 @@ _iptables()
|
||||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
chain='s/^Chain \([^ ]\+\).*$/\1/p'
|
||||
chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p'
|
||||
|
||||
if [[ $COMP_LINE == *-t\ *filter* ]]; then
|
||||
table="-t filter"
|
||||
@ -23,7 +23,7 @@ _iptables()
|
||||
case "$prev" in
|
||||
-*[AIDRPFXLZ])
|
||||
COMPREPLY=( $( compgen -W '`iptables $table -nL | \
|
||||
sed -ne "s/^Chain \([^ ]\+\).*$/\1/p"`' -- "$cur" ) )
|
||||
sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur" ) )
|
||||
;;
|
||||
-*t)
|
||||
COMPREPLY=( $( compgen -W 'nat filter mangle' -- "$cur" ) )
|
||||
|
@ -23,7 +23,8 @@ _kldunload()
|
||||
{
|
||||
local cur
|
||||
cur=`_get_cword`
|
||||
COMPREPLY=( $(kldstat | sed -ne "s/^.*[ \t]\+\($cur[a-z_]\+\).ko$/\1/p") )
|
||||
COMPREPLY=( $( kldstat | \
|
||||
sed -ne "s/^.*[ \t]\{1,\}\($cur[a-z_]\{1,\}\).ko$/\1/p" ) )
|
||||
}
|
||||
complete -F _kldunload -o filenames kldunload
|
||||
|
||||
|
@ -47,7 +47,7 @@ _mock()
|
||||
# This would actually depend on what the target root
|
||||
# can be used to build for...
|
||||
COMPREPLY=( $( compgen -W "$( command rpm --showrc | \
|
||||
sed -ne 's/^\s*compatible\s\+archs\s*:\s*\(.*\)/\1/i p' )" \
|
||||
sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p' )" \
|
||||
-- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -11,7 +11,7 @@ _rpm_installed_packages()
|
||||
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then
|
||||
# using RHL 7.2 or later - this is quicker than querying the DB
|
||||
COMPREPLY=( $( sed -ne \
|
||||
's|^\('$cur'[^[:space:]]*\)-[^[:space:]-]\+-[^[:space:]-]\+\.rpm$|\1|p' \
|
||||
's|^\('$cur'[^[:space:]]*\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \
|
||||
/var/log/rpmpkgs ) )
|
||||
elif type rpmqpack &>/dev/null ; then
|
||||
# SUSE's rpmqpack is faster than rpm -qa
|
||||
@ -97,7 +97,7 @@ _rpm()
|
||||
--eval|-E)
|
||||
# get a list of macros
|
||||
COMPREPLY=( $( rpm --showrc | sed -ne \
|
||||
's/^-\?[0-9]\+[:=][[:space:]]\+\('${cur#%}'[^[:space:](]*\).*/\1/p' ) )
|
||||
's/^-\?[0-9]\{1,\}[:=][[:space:]]\{1,\}\('${cur#%}'[^[:space:](]*\).*/\1/p' ) )
|
||||
COMPREPLY=( "${COMPREPLY[@]/#/%}" )
|
||||
return 0
|
||||
;;
|
||||
@ -139,7 +139,7 @@ _rpm()
|
||||
;;
|
||||
--target)
|
||||
COMPREPLY=( $( compgen -W "$( command rpm --showrc | sed -ne \
|
||||
's/^\s*compatible\s\+build\s\+archs\s*:\s*\(.*\)/\1/ p' )" \
|
||||
's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p' )" \
|
||||
-- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -12,7 +12,7 @@ _screen_sessions()
|
||||
fi
|
||||
|
||||
COMPREPLY=( $( command screen -ls | sed -ne \
|
||||
's|^['$'\t'']\+\('"$cur"'[0-9]\+\.[^'$'\t'']\+\)'"$pattern"'$|\1|p' ) )
|
||||
's|^['$'\t'']\{1,\}\('"$cur"'[0-9]\{1,\}\.[^'$'\t'']\{1,\}\)'"$pattern"'$|\1|p' ) )
|
||||
} &&
|
||||
_screen()
|
||||
{
|
||||
|
@ -7,10 +7,10 @@
|
||||
# @param $1 Additional sed script
|
||||
diff_env() {
|
||||
diff "$1" "$2" | sed -e "
|
||||
/^[0-9,]\+[acd]/d # Remove diff line indicators
|
||||
/---/d # Remove diff block separators
|
||||
/[<>] _=/d # Remove underscore variable
|
||||
/[<>] PPID=/d # Remove PPID bash variable
|
||||
/^[0-9,]\{1,\}[acd]/d # Remove diff line indicators
|
||||
/---/d # Remove diff block separators
|
||||
/[<>] _=/d # Remove underscore variable
|
||||
/[<>] PPID=/d # Remove PPID bash variable
|
||||
$3"
|
||||
} # diff_env()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user