From fb1a7d9d7355575cd38f7652411b6bfd02b0b924 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 17 Dec 2015 12:14:03 +0100 Subject: [PATCH] Port linux __fish_print_mounted to `string` This adds a few escape sequences, but two out of the three are theoretical and will fail a bit later. --- share/functions/__fish_print_mounted.fish | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/functions/__fish_print_mounted.fish b/share/functions/__fish_print_mounted.fish index a5e955c2d..0a454b7f2 100644 --- a/share/functions/__fish_print_mounted.fish +++ b/share/functions/__fish_print_mounted.fish @@ -2,7 +2,11 @@ function __fish_print_mounted --description 'Print mounted devices' if test -r /etc/mtab # In mtab, spaces are replaced by a literal '\040' # So it's safe to get the second "field" and then replace it - sed -e "s/[^ ]\+ \([^ ]\+\) .*/\\1/" -e "s/\\040/ /g" /etc/mtab + # \011 encodes a tab, \012 encodes a newline and \\ encodes a backslash + # This will probably break on newlines because of our splitting, though + # and tabs because of descriptions + string replace -r '\S+ (\S+) .*' '$1'