| От | Noah Misch |
|---|---|
| Тема | psql filename completion: quoting |
| Дата | |
| Msg-id | 20120114152018.GA12188@tornado.leadboat.com обсуждение |
| Ответы |
Re: psql filename completion: quoting
|
| Список | pgsql-hackers |
Occasionally, I have a SQL file destined for psql's \i command whose name contains a space. Less often, I'll have a .csv destined for \copy with the same problem. psql's filename completion does not handle these well. It completes on the literal name, but the commands will only recognize quoted names. For example, given a file "foo bar", "\i f<TAB>" will complete to "\i foo bar", which will not execute. If I type "\i 'f<TAB>", completion will not help at all. The attached patch wraps rl_filename_completion_function() to dequote on input and enquote on output. Now, "\i f<TAB>" and "\i 'f<TAB>" will both complete to "\i 'foo bar'", which executes as expected. The new code handles embedded whitespace, quotes, and backslashes. tab-complete.c works in terms of whitespace-separated words. As such, "\i 'foo b<TAB>" does not complete, because tab-complete.c has no notion of quotes affecting token boundaries. It thinks "'foo" is one token and "b" is another. I'm sure we could fix this (Bash gets it right). It seemed rather independent code-wise, so I did not attempt that for this patch. Thanks, nm
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера