Fixed bash completion for filenames with spaces.

Closes #2749.
This commit is contained in:
John MacFarlane 2016-12-07 15:46:46 +01:00
parent a197341252
commit b0733190b0
2 changed files with 23 additions and 6 deletions

View file

@ -1,5 +1,3 @@
#!/bin/bash
# This script enables bash autocompletion for pandoc. To enable
# bash completion, add this to your .bashrc:
# eval "$(pandoc --bash-completion)"
@ -15,6 +13,7 @@ _pandoc()
opts="%s"
informats="%s"
outformats="%s"
highlight_styles="%s"
datadir="%s"
case "${prev}" in
@ -38,8 +37,24 @@ _pandoc()
COMPREPLY=( $(compgen -W "reference.odt reference.docx $(find ${datadir} | sed -e 's/.*\/data\///')" -- ${cur}) )
return 0
;;
--wrap)
COMPREPLY=( $(compgen -W "auto none preserve" -- ${cur}) )
return 0
;;
--track-changes)
COMPREPLY=( $(compgen -W "accept reject all" -- ${cur}) )
return 0
;;
--reference-location)
COMPREPLY=( $(compgen -W "block section document" -- ${cur}) )
return 0
;;
--top-level-division)
COMPREPLY=( $(compgen -W "section chapter part" -- ${cur}) )
return 0
;;
--highlight-style)
COMPREPLY=( $(compgen -W "pygments tango espresso zenburn kate monochrome haddock" -- ${cur}) )
COMPREPLY=( $(compgen -W "${highlight_styles}" -- ${cur}) )
return 0
;;
*)
@ -52,7 +67,8 @@ _pandoc()
return 0
;;
*)
COMPREPLY=( $(compgen -f ${cur}) )
local IFS=$'\n'
COMPREPLY=( $(compgen -X '' -f ${cur}) )
return 0
;;
esac

View file

@ -478,7 +478,7 @@ options =
case safeRead ("Wrap" ++ uppercaseFirstLetter arg) of
Just o -> return opt { optWrapText = o }
Nothing -> err 77 "--wrap must be auto, none, or preserve")
"[auto|none|preserve]")
"auto|none|preserve")
"" -- "Option for wrapping text in output"
, Option "" ["columns"]
@ -609,7 +609,7 @@ options =
Just tlDiv -> return opt { optTopLevelDivision = tlDiv }
_ -> err 76 ("Top-level division must be " ++
"section, chapter, part, or default"))
"[section|chapter|part]")
"section|chapter|part")
"" -- "Use top-level division type in LaTeX, ConTeXt, DocBook"
, Option "N" ["number-sections"]
@ -912,6 +912,7 @@ options =
UTF8.hPutStrLn stdout $ printf tpl allopts
(unwords (map fst readers))
(unwords (map fst writers))
(unwords $ map fst highlightingStyles)
ddir
exitSuccess ))
"" -- "Print bash completion script"