Compare commits

...

4 Commits

Author SHA1 Message Date
Bram Moolenaar
ddb349369d patch 8.0.1458: filetype detection test does not check all scripts
Problem:    Filetype detection test does not check all scripts.
Solution:   Add most scripts to the test
2018-02-03 15:55:49 +01:00
Bram Moolenaar
8fd2ffc530 patch 8.0.1457: clojure now supports a shebang line
Problem:    Clojure now supports a shebang line.
Solution:   Detect clojure script from the shebang line. (David Burgin,
            closes #2570)
2018-02-03 15:43:15 +01:00
Bram Moolenaar
8dce6c54c8 patch 8.0.1456: timer test on travis Mac is still flaky
Problem:    Timer test on travis Mac is still flaky.
Solution:   Increase time range a bit more.
2018-02-03 15:38:42 +01:00
Bram Moolenaar
4bfa8af141 patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Problem:    If $SHELL contains a space then the default value of 'shell' is
            incorrect. (Matthew Horan)
Solution:   Escape spaces in $SHELL. (Christian Brabandt, closes #459)
2018-02-03 15:14:46 +01:00
7 changed files with 90 additions and 8 deletions

View File

@@ -6630,14 +6630,21 @@ A jump table for the options with a short description can be found at |Q_op|.
It is allowed to give an argument to the command, e.g. "csh -f". It is allowed to give an argument to the command, e.g. "csh -f".
See |option-backslash| about including spaces and backslashes. See |option-backslash| about including spaces and backslashes.
Environment variables are expanded |:set_env|. Environment variables are expanded |:set_env|.
If the name of the shell contains a space, you might need to enclose If the name of the shell contains a space, you might need to enclose
it in quotes. Example: > it in quotes or escape the space. Example with quotes: >
:set shell=\"c:\program\ files\unix\sh.exe\"\ -f :set shell=\"c:\program\ files\unix\sh.exe\"\ -f
< Note the backslash before each quote (to avoid starting a comment) and < Note the backslash before each quote (to avoid starting a comment) and
each space (to avoid ending the option value). Also note that the each space (to avoid ending the option value). Also note that the
"-f" is not inside the quotes, because it is not part of the command "-f" is not inside the quotes, because it is not part of the command
name. And Vim automagically recognizes the backslashes that are path name. Vim automagically recognizes the backslashes that are path
separators. separators.
Example with escaped space (Vim will do this when initializing the
option from $SHELL): >
:set shell=/bin/with\\\ space/sh
< The resulting value of 'shell' is "/bin/with\ space/sh", two
backslashes are consumed by `:set`.
Under MS-Windows, when the executable ends in ".com" it must be Under MS-Windows, when the executable ends in ".com" it must be
included. Thus setting the shell to "command.com" or "4dos.com" included. Thus setting the shell to "command.com" or "4dos.com"
works, but "command" and "4dos" do not work for all commands (e.g., works, but "command" and "4dos" do not work for all commands (e.g.,

View File

@@ -1,7 +1,7 @@
" Vim support file to detect file types in scripts " Vim support file to detect file types in scripts
" "
" Maintainer: Bram Moolenaar <Bram@vim.org> " Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2017 Nov 11 " Last change: 2018 Feb 03
" This file is called by an autocommand for every file that has just been " This file is called by an autocommand for every file that has just been
" loaded into a buffer. It checks if the type of file can be recognized by " loaded into a buffer. It checks if the type of file can be recognized by
@@ -104,6 +104,10 @@ if s:line1 =~# "^#!"
elseif s:name =~# '^pike\%(\>\|[0-9]\)' elseif s:name =~# '^pike\%(\>\|[0-9]\)'
set ft=pike set ft=pike
" Pike
elseif s:name =~# '^pike\%(\>\|[0-9]\)'
set ft=pike
" Lua " Lua
elseif s:name =~# 'lua' elseif s:name =~# 'lua'
set ft=lua set ft=lua
@@ -176,6 +180,10 @@ if s:line1 =~# "^#!"
elseif s:name =~# 'scala\>' elseif s:name =~# 'scala\>'
set ft=scala set ft=scala
" Clojure
elseif s:name =~# 'clojure'
set ft=clojure
endif endif
unlet s:name unlet s:name

View File

@@ -3265,6 +3265,7 @@ static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
static void set_option_default(int, int opt_flags, int compatible); static void set_option_default(int, int opt_flags, int compatible);
static void set_options_default(int opt_flags); static void set_options_default(int opt_flags);
static void set_string_default_esc(char *name, char_u *val, int escape);
static char_u *term_bg_default(void); static char_u *term_bg_default(void);
static void did_set_option(int opt_idx, int opt_flags, int new_value); static void did_set_option(int opt_idx, int opt_flags, int new_value);
static char_u *illegal_char(char_u *, int); static char_u *illegal_char(char_u *, int);
@@ -3371,7 +3372,7 @@ set_init_1(void)
# endif # endif
#endif #endif
) )
set_string_default("sh", p); set_string_default_esc("sh", p, TRUE);
#ifdef FEAT_WILDIGN #ifdef FEAT_WILDIGN
/* /*
@@ -3859,14 +3860,18 @@ set_options_default(
/* /*
* Set the Vi-default value of a string option. * Set the Vi-default value of a string option.
* Used for 'sh', 'backupskip' and 'term'. * Used for 'sh', 'backupskip' and 'term'.
* When "escape" is TRUE escape spaces with a backslash.
*/ */
void static void
set_string_default(char *name, char_u *val) set_string_default_esc(char *name, char_u *val, int escape)
{ {
char_u *p; char_u *p;
int opt_idx; int opt_idx;
p = vim_strsave(val); if (escape && vim_strchr(val, ' ') != NULL)
p = vim_strsave_escaped(val, (char_u *)" ");
else
p = vim_strsave(val);
if (p != NULL) /* we don't want a NULL */ if (p != NULL) /* we don't want a NULL */
{ {
opt_idx = findoption((char_u *)name); opt_idx = findoption((char_u *)name);
@@ -3880,6 +3885,12 @@ set_string_default(char *name, char_u *val)
} }
} }
void
set_string_default(char *name, char_u *val)
{
set_string_default_esc(name, val, FALSE);
}
/* /*
* Set the Vi-default value of a number option. * Set the Vi-default value of a number option.
* Used for 'lines' and 'columns'. * Used for 'lines' and 'columns'.

View File

@@ -542,6 +542,40 @@ let s:script_checks = {
\ 'strace': [['execve("/usr/bin/pstree", ["pstree"], 0x7ff0 /* 63 vars */) = 0'], \ 'strace': [['execve("/usr/bin/pstree", ["pstree"], 0x7ff0 /* 63 vars */) = 0'],
\ ['15:17:47 execve("/usr/bin/pstree", ["pstree"], ... "_=/usr/bin/strace"]) = 0'], \ ['15:17:47 execve("/usr/bin/pstree", ["pstree"], ... "_=/usr/bin/strace"]) = 0'],
\ ['__libc_start_main and something']], \ ['__libc_start_main and something']],
\ 'clojure': [['#!/path/clojure']],
\ 'scala': [['#!/path/scala']],
\ 'tcsh': [['#!/path/tcsh']],
\ 'zsh': [['#!/path/zsh']],
\ 'tcl': [['#!/path/tclsh'],
\ ['#!/path/wish'],
\ ['#!/path/expectk'],
\ ['#!/path/itclsh'],
\ ['#!/path/itkwish']],
\ 'expect': [['#!/path/expect']],
\ 'gnuplot': [['#!/path/gnuplot']],
\ 'make': [['#!/path/make']],
\ 'pike': [['#!/path/pike'],
\ ['#!/path/pike0'],
\ ['#!/path/pike9']],
\ 'lua': [['#!/path/lua']],
\ 'perl6': [['#!/path/perl6']],
\ 'perl': [['#!/path/perl']],
\ 'php': [['#!/path/php']],
\ 'python': [['#!/path/python']],
\ 'groovy': [['#!/path/groovy']],
\ 'ruby': [['#!/path/ruby']],
\ 'javascript': [['#!/path/node'],
\ ['#!/path/nodejs'],
\ ['#!/path/rhino']],
\ 'bc': [['#!/path/bc']],
\ 'sed': [['#!/path/sed']],
\ 'ocaml': [['#!/path/ocaml']],
\ 'awk': [['#!/path/awk']],
\ 'wml': [['#!/path/wml']],
\ 'scheme': [['#!/path/scheme']],
\ 'cfengine': [['#!/path/cfengine']],
\ 'erlang': [['#!/path/escript']],
\ 'haskell': [['#!/path/haskell']],
\ } \ }
func Test_script_detection() func Test_script_detection()

View File

@@ -226,6 +226,20 @@ func Test_read_stdin()
call delete('Xtestout') call delete('Xtestout')
endfunc endfunc
func Test_set_shell()
let after = [
\ 'call writefile([&shell], "Xtestout")',
\ 'quit!',
\ ]
let $SHELL = '/bin/with space/sh'
if RunVimPiped([], after, '', '')
let lines = readfile('Xtestout')
" MS-Windows adds a space after the word
call assert_equal('/bin/with\ space/sh', lines[0])
endif
call delete('Xtestout')
endfunc
func Test_progpath() func Test_progpath()
" Tests normally run with "./vim" or "../vim", these must have been expanded " Tests normally run with "./vim" or "../vim", these must have been expanded
" to a full path. " to a full path.

View File

@@ -124,7 +124,7 @@ func Test_paused()
if has('reltime') if has('reltime')
if has('mac') if has('mac')
" The travis Mac machines appear to be very busy. " The travis Mac machines appear to be very busy.
call assert_inrange(0, 40, slept) call assert_inrange(0, 50, slept)
else else
call assert_inrange(0, 30, slept) call assert_inrange(0, 30, slept)
endif endif

View File

@@ -771,6 +771,14 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1458,
/**/
1457,
/**/
1456,
/**/
1455,
/**/ /**/
1454, 1454,
/**/ /**/