Fix other usages of \n in sed replacements.

This commit is contained in:
Evan Jones 2012-06-17 07:17:05 -04:00 committed by ridiculousfish
parent 1fa0c4d4d3
commit 01780f19b1
3 changed files with 15 additions and 3 deletions

View file

@ -2,7 +2,11 @@ function __fish_complete_command --description 'Complete using all available com
set -l ctoken (commandline -ct)
switch $ctoken
case '*=*'
set ctoken (echo $ctoken | sed 's/=/\n/')
# Some seds (e.g. on Mac OS X), don't support \n in the RHS
# Use a literal newline instead
# http://sed.sourceforge.net/sedfaq4.html#s4.1
set ctoken (echo $ctoken | sed 's/=/\\
/')
printf '%s\n' $ctoken[1]=(complete -C$ctoken[2])
case '*'
complete -C$ctoken

View file

@ -5,7 +5,11 @@ function __fish_complete_lpr_option --description 'Complete lpr option'
set -l IFS =
echo $optstr | read -l opt val
set -l descr
for l in (lpoptions -l ^ /dev/null | grep $opt | sed 's+\(.*\)/\(.*\):\s*\(.*\)$+\2 \3+; s/ /\n/g;')
# Some seds (e.g. on Mac OS X), don't support \n in the RHS
# Use a literal newline instead
# http://sed.sourceforge.net/sedfaq4.html#s4.1
for l in (lpoptions -l ^ /dev/null | grep $opt | sed 's+\(.*\)/\(.*\):\s*\(.*\)$+\2 \3+; s/ /\\
/g;')
if not set -q descr[1]
set descr $l
continue

View file

@ -1,4 +1,8 @@
function __fish_print_make_targets
set files Makefile makefile GNUmakefile
sgrep -h -E '^[^#%=$[:space:]][^#%=$]*:([^=]|$)' $files | cut -d ":" -f 1 | sed -e 's/^ *//;s/ *$//;s/ */\n/g' ^/dev/null
# Some seds (e.g. on Mac OS X), don't support \n in the RHS
# Use a literal newline instead
# http://sed.sourceforge.net/sedfaq4.html#s4.1
sgrep -h -E '^[^#%=$[:space:]][^#%=$]*:([^=]|$)' $files | cut -d ":" -f 1 | sed -e 's/^ *//;s/ *$//;s/ */\\
/g' ^/dev/null
end