Replace sed -E with string replace

This is to the benefit of systems with ancient GNU sed, which does not
recognize "-E", but only "-r".

Fixes #2305 - even if it doesn't replace all `sed -E` invocations in the
codebase, the others are unlikely to occur on CentOS and other similarly
crusty systems.
This commit is contained in:
Fabian Homborg 2015-09-28 20:06:20 +02:00
parent 37f4cbe3d7
commit b9b39f7c31
2 changed files with 2 additions and 6 deletions

View File

@ -5,11 +5,7 @@ function __fish_complete_pids -d "Print a list of process identifiers along with
set -l SELF %self
# Display the tty if available
set -l sed_cmds 's/ *([0-9]+) +([^ ].*[^ ]|[^ ]) +([^ ]+) *$/\1'\t'\2 [\3]/'
# But not if it's just question marks, meaning no tty
set -l sed_cmds $sed_cmds 's/ *\[\?*\] *$//'
ps axc -o pid,ucomm,tty | grep -v '^\s*'$SELF'\s' | tail -n +2 | sed -E "-e "$sed_cmds ^/dev/null
ps axc -o pid,ucomm,tty | grep -v '^\s*'$SELF'\s' | tail -n +2 | string replace -r ' *([0-9]+) +([^ ].*[^ ]|[^ ]) +([^ ]+) *$' '$1\t$2 [$3]' | string replace -r ' *\[\?*\] *$' ''
end

View File

@ -14,7 +14,7 @@ function __fish_print_hostnames -d "Print a list of known hostnames"
# Print hosts with known ssh keys
# Does not match hostnames with @directives specified
__fish_sgrep -Eoh '^[^#@|, ]*' ~/.ssh/known_hosts{,2} ^/dev/null | sed -E 's/^\[([^]]+)\]:([0-9]+)$/\1/'
__fish_sgrep -Eoh '^[^#@|, ]*' ~/.ssh/known_hosts{,2} ^/dev/null | string replace -r '^\[([^]]+)\]:[0-9]+$' '$1'
# Print hosts from system wide ssh configuration file
if [ -e /etc/ssh/ssh_config ]