Merge branch 'master' into ast

Conflicts:
	complete.cpp
This commit is contained in:
ridiculousfish
2013-10-27 13:37:14 -07:00
28 changed files with 167 additions and 107 deletions

View File

@@ -66,6 +66,12 @@ To switch your default shell back, you can run:
Substitute /bin/bash with /bin/tcsh or /bin/zsh as appropriate. Substitute /bin/bash with /bin/tcsh or /bin/zsh as appropriate.
## Optional Dependencies
In order to generate completions from man pages compressed with either lzma or xz, you may need to install an extra Python package.
Python versions prior to 2.6 are not supported. For Python versions 2.6 to 3.2 you need to install the module `backports.lzma`. How to install it depends on your system and how you installed Python. Most Linux distributions should include it as a package named `backports-lzma` (or similar). From version 3.3 onwards, Python already includes the required module.
## Contact Us ## Contact Us
Questions, comments, rants and raves can be posted to the official fish mailing list at <https://lists.sourceforge.net/lists/listinfo/fish-users> or join us on our IRC channel [#fish at irc.oftc.net](https://webchat.oftc.net/?channels=fish). Questions, comments, rants and raves can be posted to the official fish mailing list at <https://lists.sourceforge.net/lists/listinfo/fish-users> or join us on our IRC channel [#fish at irc.oftc.net](https://webchat.oftc.net/?channels=fish).

View File

@@ -1618,24 +1618,24 @@ static int builtin_echo(parser_t &parser, wchar_t **argv)
{ {
case L'n': case L'n':
print_newline = false; print_newline = false;
break; break;
case L'e': case L'e':
interpret_special_chars = true; interpret_special_chars = true;
break; break;
case L's': case L's':
// fish-specific extension, // fish-specific extension,
// which we should try to nix // which we should try to nix
print_spaces = false; print_spaces = false;
break; break;
case L'E': case L'E':
interpret_special_chars = false; interpret_special_chars = false;
break; break;
} }
} }
} }
else else
{ {
invalid_echo_option: invalid_echo_option:
break; break;
} }
argv++; argv++;

View File

@@ -698,7 +698,6 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
Slice mode Slice mode
*/ */
size_t idx_count, val_count; size_t idx_count, val_count;
wcstring_list_t values;
std::vector<long> indexes; std::vector<long> indexes;
wcstring_list_t result; wcstring_list_t result;

View File

@@ -1630,7 +1630,7 @@ void completer_t::complete_param_expand(const wcstring &sstr, bool do_file)
if (expand_string(comp_str, if (expand_string(comp_str,
this->completions, this->completions,
flags ) == EXPAND_ERROR) flags) == EXPAND_ERROR)
{ {
debug(3, L"Error while expanding string '%ls'", comp_str); debug(3, L"Error while expanding string '%ls'", comp_str);
} }

View File

@@ -398,6 +398,9 @@ start_conversion:
{ {
debug(0, L"%d %d", in_len, out_len); debug(0, L"%d %d", in_len, out_len);
debug(0, L"Error while converting from to string"); debug(0, L"Error while converting from to string");
/* Terminate the output string. */
free(out);
return 0; return 0;
} }

View File

@@ -1760,7 +1760,7 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
// Don't do wildcard expansion for executables. See #785. So do nothing here. // Don't do wildcard expansion for executables. See #785. So do nothing here.
} }
else if (((flags & ACCEPT_INCOMPLETE) && (!(flags & EXPAND_SKIP_WILDCARDS))) || else if (((flags & ACCEPT_INCOMPLETE) && (!(flags & EXPAND_SKIP_WILDCARDS))) ||
has_wildcard) has_wildcard)
{ {
const wchar_t *start, *rest; const wchar_t *start, *rest;

View File

@@ -98,8 +98,6 @@ char *tparm_solaris_kludge(char *str, ...)
|| (enter_reverse_mode && ! strcmp(str, enter_reverse_mode)) || (enter_reverse_mode && ! strcmp(str, enter_reverse_mode))
|| (enter_shadow_mode && ! strcmp(str, enter_shadow_mode)) || (enter_shadow_mode && ! strcmp(str, enter_shadow_mode))
|| (exit_shadow_mode && ! strcmp(str, exit_shadow_mode)) || (exit_shadow_mode && ! strcmp(str, exit_shadow_mode))
|| (enter_standout_mode && ! strcmp(str, enter_standout_mode))
|| (exit_standout_mode && ! strcmp(str, exit_standout_mode))
|| (enter_secure_mode && ! strcmp(str, enter_secure_mode)) || (enter_secure_mode && ! strcmp(str, enter_secure_mode))
|| (enter_bold_mode && ! strcmp(str, enter_bold_mode))) || (enter_bold_mode && ! strcmp(str, enter_bold_mode)))
{ {

View File

@@ -365,18 +365,15 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *out_c
is_login |= (strcmp(argv[0], "-fish") == 0); is_login |= (strcmp(argv[0], "-fish") == 0);
/* /* We are an interactive session if we are either forced, or have not been given an explicit command to execute and stdin is a tty. */
We are an interactive session if we have not been given an if (force_interactive)
explicit command to execute, _and_ stdin is a tty. {
*/ is_interactive_session = true;
is_interactive_session &= ! has_cmd; }
is_interactive_session &= (my_optind == argc); else if (is_interactive_session)
is_interactive_session &= isatty(STDIN_FILENO); {
is_interactive_session = ! has_cmd && (my_optind == argc) && isatty(STDIN_FILENO);
/* }
We are also an interactive session if we have are forced-
*/
is_interactive_session |= force_interactive;
return my_optind; return my_optind;
} }
@@ -389,7 +386,6 @@ int main(int argc, char **argv)
set_main_thread(); set_main_thread();
setup_fork_guards(); setup_fork_guards();
save_term_foreground_process_group();
wsetlocale(LC_ALL, L""); wsetlocale(LC_ALL, L"");
is_interactive_session=1; is_interactive_session=1;
@@ -410,6 +406,12 @@ int main(int argc, char **argv)
no_exec = 0; no_exec = 0;
} }
/* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */
if (is_interactive_session)
{
save_term_foreground_process_group();
}
const struct config_paths_t paths = determine_config_directory_paths(argv[0]); const struct config_paths_t paths = determine_config_directory_paths(argv[0]);
proc_init(); proc_init();
@@ -511,6 +513,7 @@ int main(int argc, char **argv)
proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res); proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res);
restore_term_mode();
restore_term_foreground_process_group(); restore_term_foreground_process_group();
history_destroy(); history_destroy();
proc_destroy(); proc_destroy();

View File

@@ -694,7 +694,7 @@ static void daemonize()
} }
/* /*
Put ourself in out own processing group Put ourself in our own process group
*/ */
setsid(); setsid();

View File

@@ -2047,7 +2047,7 @@ int parser_t::parse_job(process_t *p,
/* Looks like a command */ /* Looks like a command */
debug(0, debug(0,
_( L"Unknown command '%ls'. Did you mean to run %ls with a modified environment? Try 'env %ls=%ls %ls%ls'. See the help section on the set command by typing 'help set'."), _(L"Unknown command '%ls'. Did you mean to run %ls with a modified environment? Try 'env %ls=%ls %ls%ls'. See the help section on the set command by typing 'help set'."),
cmd, cmd,
next_str.c_str(), next_str.c_str(),
name_str.c_str(), name_str.c_str(),

5
proc.h
View File

@@ -373,7 +373,10 @@ class job_t
unsigned int flags; unsigned int flags;
/* Returns the block IO redirections associated with the job. These are things like the IO redirections associated with the begin...end statement. */ /* Returns the block IO redirections associated with the job. These are things like the IO redirections associated with the begin...end statement. */
const io_chain_t &block_io_chain() const { return this->block_io; } const io_chain_t &block_io_chain() const
{
return this->block_io;
}
/* Fetch all the IO redirections associated with the job */ /* Fetch all the IO redirections associated with the job */
io_chain_t all_io_redirections() const; io_chain_t all_io_redirections() const;

View File

@@ -923,19 +923,27 @@ void reader_init()
// PCA disable VDSUSP (typically control-Y), which is a funny job control // PCA disable VDSUSP (typically control-Y), which is a funny job control
// function available only on OS X and BSD systems // function available only on OS X and BSD systems
// This lets us use control-Y for yank instead // This lets us use control-Y for yank instead
#ifdef VDSUSP #ifdef VDSUSP
shell_modes.c_cc[VDSUSP] = _POSIX_VDISABLE; shell_modes.c_cc[VDSUSP] = _POSIX_VDISABLE;
#endif #endif
#endif #endif
} }
void reader_destroy() void reader_destroy()
{ {
tcsetattr(0, TCSANOW, &terminal_mode_on_startup);
pthread_key_delete(generation_count_key); pthread_key_delete(generation_count_key);
} }
void restore_term_mode()
{
// Restore the term mode if we own the terminal
// It's important we do this before restore_foreground_process_group, otherwise we won't think we own the terminal
if (getpid() == tcgetpgrp(STDIN_FILENO))
{
tcsetattr(STDIN_FILENO, TCSANOW, &terminal_mode_on_startup);
}
}
void reader_exit(int do_exit, int forced) void reader_exit(int do_exit, int forced)
{ {

View File

@@ -46,6 +46,9 @@ void reader_init();
*/ */
void reader_destroy(); void reader_destroy();
/** Restore the term mode at startup */
void restore_term_mode();
/** /**
Returns the filename of the file currently read Returns the filename of the file currently read
*/ */

View File

@@ -2,7 +2,7 @@ begin
set -l unicode 'commandline | sgrep -qe "-[a-zA-Z]*C[a-zA-Z]*\$"' set -l unicode 'commandline | sgrep -qe "-[a-zA-Z]*C[a-zA-Z]*\$"'
set -l noopt 'commandline | not sgrep -qe "-[a-zA-Z]*C[a-zA-Z]*\$"' set -l noopt 'commandline | not sgrep -qe "-[a-zA-Z]*C[a-zA-Z]*\$"'
set -l modules "(find (perl -lE'print for @INC') -name '*.pm' -printf '%P\n' \ set -l modules "(find (perl -lE'print for @INC') -name '*.pm' -printf '%P\n' \
| awk '{ gsub(\"/\", \"::\") } !/-/' RS=.pm\n | sort | uniq)" | awk '{ gsub(\"/\", \"::\") } /[^-.]/' RS=.pm\n | sort | uniq)"
complete -c perl -s 0 -n $noopt --description 'Specify record separator' complete -c perl -s 0 -n $noopt --description 'Specify record separator'
complete -c perl -s a -n $noopt --description 'Turn on autosplit mode' complete -c perl -s a -n $noopt --description 'Turn on autosplit mode'
complete -c perl -s c -n $noopt --description 'Check syntax' complete -c perl -s c -n $noopt --description 'Check syntax'

View File

@@ -51,6 +51,7 @@
# __fish_git_prompt_showupstream to a space-separated list of values: # __fish_git_prompt_showupstream to a space-separated list of values:
# #
# verbose show number of commits ahead/behind (+/-) upstream # verbose show number of commits ahead/behind (+/-) upstream
# name if verbose, then also show the upstream abbrev name
# informative similar to verbose, but shows nothing when equal (fish only) # informative similar to verbose, but shows nothing when equal (fish only)
# legacy don't use the '--count' option available in recent versions # legacy don't use the '--count' option available in recent versions
# of git-rev-list # of git-rev-list
@@ -155,7 +156,8 @@
# #
# The separator before the upstream information can be customized via # The separator before the upstream information can be customized via
# __fish_git_prompt_char_upstream_prefix. It is colored like the rest of # __fish_git_prompt_char_upstream_prefix. It is colored like the rest of
# the upstream information. It defaults to nothing (). # the upstream information. It normally defaults to nothing () and defaults
# to a space ( ) when __fish_git_prompt_showupstream contains verbose.
# #
# #
# Turning on __fish_git_prompt_showcolorhints changes the colors as follows to # Turning on __fish_git_prompt_showcolorhints changes the colors as follows to
@@ -178,6 +180,7 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
set -l upstream git set -l upstream git
set -l legacy set -l legacy
set -l verbose set -l verbose
set -l name
# Default to informative if show_informative_status is set # Default to informative if show_informative_status is set
if test -n "$__fish_git_prompt_show_informative_status" if test -n "$__fish_git_prompt_show_informative_status"
@@ -222,6 +225,8 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
case legacy case legacy
set legacy 1 set legacy 1
set -e informative set -e informative
case name
set name 1
case none case none
return return
end end
@@ -291,17 +296,27 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
# calculate the result # calculate the result
if test -n "$verbose" if test -n "$verbose"
# Verbose has a space by default
set -l prefix "$___fish_git_prompt_char_upstream_prefix"
# Using two underscore version to check if user explicitly set to nothing
if not set -q __fish_git_prompt_char_upstream_prefix
set -l prefix " "
end
echo $count | read -l behind ahead echo $count | read -l behind ahead
switch "$count" switch "$count"
case '' # no upstream case '' # no upstream
case "0 0" # equal to upstream case "0 0" # equal to upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_equal" echo "$prefix$___fish_git_prompt_char_upstream_equal"
case "0 *" # ahead of upstream case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead" echo "$prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind" echo "$prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind" echo "$prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind"
end
if test -n "$count" -a -n "$name"
echo " "(command git rev-parse --abbrev-ref "$upstream" ^/dev/null)
end end
else if test -n "$informative" else if test -n "$informative"
echo $count | read -l behind ahead echo $count | read -l behind ahead
@@ -657,21 +672,12 @@ function __fish_git_prompt_set_color
set default_done "$argv[3]" set default_done "$argv[3]"
end end
if test (count $user_variable) -eq 2
set user_variable_bright $user_variable[2]
set user_variable $user_variable[1]
end
set -l variable _$user_variable_name set -l variable _$user_variable_name
set -l variable_done "$variable"_done set -l variable_done "$variable"_done
if not set -q $variable if not set -q $variable
if test -n "$user_variable" if test -n "$user_variable"
if test -n "$user_variable_bright" set -g $variable (set_color $user_variable)
set -g $variable (set_color --bold $user_variable)
else
set -g $variable (set_color $user_variable)
end
set -g $variable_done (set_color normal) set -g $variable_done (set_color normal)
else else
set -g $variable $default set -g $variable $default

View File

@@ -17,9 +17,18 @@ Redistributions in binary form must reproduce the above copyright notice, this l
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
""" """
import string, sys, re, os.path, gzip, traceback, getopt, errno, codecs import string, sys, re, os.path, bz2, gzip, traceback, getopt, errno, codecs
from deroff import Deroffer from deroff import Deroffer
lzma_available = True
try:
try:
import backports.lzma as lzma
except ImportError:
import lzma
except ImportError:
lzma_available = False
# Whether we're Python 3 # Whether we're Python 3
IS_PY3 = sys.version_info[0] >= 3 IS_PY3 = sys.version_info[0] >= 3
@@ -717,6 +726,16 @@ def parse_manpage_at_path(manpage_path, output_directory):
fd = gzip.open(manpage_path, 'r') fd = gzip.open(manpage_path, 'r')
manpage = fd.read() manpage = fd.read()
if IS_PY3: manpage = manpage.decode('latin-1') if IS_PY3: manpage = manpage.decode('latin-1')
elif manpage_path.endswith('.bz2'):
fd = bz2.BZ2File(manpage_path, 'r')
manpage = fd.read()
if IS_PY3: manpage = manpage.decode('latin-1')
elif manpage_path.endswith('.xz') or manpage_path.endswith('.lzma'):
if not lzma_available:
return
fd = lzma.LZMAFile(str(manpage_path), 'r')
manpage = fd.read()
if IS_PY3: manpage = manpage.decode('latin-1')
else: else:
if IS_PY3: if IS_PY3:
fd = open(manpage_path, 'r', encoding='latin-1') fd = open(manpage_path, 'r', encoding='latin-1')
@@ -816,6 +835,15 @@ def parse_and_output_man_pages(paths, output_directory, show_progress):
last_progress_string_length = 0 last_progress_string_length = 0
if show_progress and not WRITE_TO_STDOUT: if show_progress and not WRITE_TO_STDOUT:
print("Parsing man pages and writing completions to {0}".format(output_directory)) print("Parsing man pages and writing completions to {0}".format(output_directory))
man_page_suffixes = set([os.path.splitext(m)[1][1:] for m in paths])
lzma_xz_occurs = "xz" in man_page_suffixes or "lzma" in man_page_suffixes
if lzma_xz_occurs and not lzma_available:
add_diagnostic('At least one man page is compressed with lzma or xz, but the "lzma" module is not available.'
' Any man page compressed with either will be skipped.',
NOT_VERBOSE)
flush_diagnostics(sys.stderr)
for manpage_path in paths: for manpage_path in paths:
index += 1 index += 1

View File

@@ -276,7 +276,10 @@ _xdg_mime_magic_parse_header(FILE *magic_file, XdgMimeMagicMatch *match)
buffer = _xdg_mime_magic_read_to_newline(magic_file, &end_of_file); buffer = _xdg_mime_magic_read_to_newline(magic_file, &end_of_file);
if (end_of_file) if (end_of_file)
{
free(buffer);
return XDG_MIME_MAGIC_EOF; return XDG_MIME_MAGIC_EOF;
}
end_ptr = buffer; end_ptr = buffer;
while (*end_ptr != ']' && *end_ptr != '\000' && *end_ptr != '\n') while (*end_ptr != ']' && *end_ptr != '\000' && *end_ptr != '\n')