diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2015-12-17 12:14:03 +0100 |
---|---|---|
committer | Fabian Homborg <FHomborg@gmail.com> | 2015-12-17 12:14:03 +0100 |
commit | fb1a7d9d7355575cd38f7652411b6bfd02b0b924 (patch) | |
tree | 0ea912d0b95d25e9692eea40f0c77dfe7abc93f3 /share/functions/__fish_print_mounted.fish | |
parent | 482cfca84f622100e88086e223df776d6240acdb (diff) |
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.
Diffstat (limited to 'share/functions/__fish_print_mounted.fish')
-rw-r--r-- | share/functions/__fish_print_mounted.fish | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/share/functions/__fish_print_mounted.fish b/share/functions/__fish_print_mounted.fish index a5e955c2..0a454b7f 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' </etc/mtab | string replace -a "\040" " " \ + | string replace -a "\011" \t | string replace -a "\012" \n | string replace -a "\\\\" "\\" else mount | cut -d " " -f 1-3|tr " " \n|sed -e "s/[0-9\.]*:\//\//"| __fish_sgrep "^/" end |