From 01780f19b1ffda0026e44a116d27d887dbfb096e Mon Sep 17 00:00:00 2001 From: Evan Jones Date: Sun, 17 Jun 2012 07:17:05 -0400 Subject: [PATCH] Fix other usages of \n in sed replacements. --- share/functions/__fish_complete_command.fish | 6 +++++- share/functions/__fish_complete_lpr_option.fish | 6 +++++- share/functions/__fish_print_make_targets.fish | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/share/functions/__fish_complete_command.fish b/share/functions/__fish_complete_command.fish index 8dc1d3114..983366db6 100644 --- a/share/functions/__fish_complete_command.fish +++ b/share/functions/__fish_complete_command.fish @@ -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 diff --git a/share/functions/__fish_complete_lpr_option.fish b/share/functions/__fish_complete_lpr_option.fish index 287b13ebf..aa9d981f0 100644 --- a/share/functions/__fish_complete_lpr_option.fish +++ b/share/functions/__fish_complete_lpr_option.fish @@ -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 diff --git a/share/functions/__fish_print_make_targets.fish b/share/functions/__fish_print_make_targets.fish index c57e88713..bda806f46 100644 --- a/share/functions/__fish_print_make_targets.fish +++ b/share/functions/__fish_print_make_targets.fish @@ -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