Stringify __fish_complete_lpr_option

This commit is contained in:
Fabian Homborg 2016-02-03 23:26:41 +01:00
parent 158ea98189
commit 16aa0b93e9

View file

@ -5,24 +5,20 @@ function __fish_complete_lpr_option --description 'Complete lpr option'
set -l IFS = set -l IFS =
echo $optstr | read -l opt val echo $optstr | read -l opt val
set -l descr set -l descr
# Some seds (e.g. on Mac OS X), don't support \n in the RHS for l in (lpoptions -l ^/dev/null | string match -- "*$opt*" | string replace -r '.*/(.*):\s*(.*)$' '$1 $2' | string split " ")
# 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] if not set -q descr[1]
set descr $l set descr $l
continue continue
end end
set -l default '' set -l default ''
if test (expr substr $l 1 1) = '*' if string match -q '\**' -- $l
set default 'Default ' set default 'Default '
set l (echo $l | sed 's/\*//') set l (string sub -s 2 -- $l)
end end
echo $opt=$l\t$default$descr echo $opt=$l\t$default$descr
end end
case '*' case '*'
lpoptions -l ^ /dev/null | sed 's+\(.*\)/\(.*\):.*$+\1=\t\2+' lpoptions -l ^/dev/null | string replace -r '(.*)/(.*):.*$' '$1=\t$2'
end end