From ea407476d0e8bfe8b179dbb43bdecb6bdbd2acbb Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 12 Jun 2015 16:05:59 -0700 Subject: Correctly un-export an env var when it is shadowed Prior to this fix, if you exported a variable in one scope and then unexported it in the next, it would remain exported. Example: set -gx VAR 1 function foo; set -l VAR; env; end foo Here 'VAR' would be exported to 'env' because we failed to notice that the env var is shadowed by an unexported variable. This occurred at env var computation time, not in env_set! Fixes #2132 --- env.cpp | 19 ++++++++++++++----- tests/test3.in | 8 ++++++++ tests/test3.out | 2 ++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/env.cpp b/env.cpp index 1a04665e..6b09c07f 100644 --- a/env.cpp +++ b/env.cpp @@ -1264,7 +1264,7 @@ wcstring_list_t env_get_names(int flags) Get list of all exported variables */ -static void get_exported(const env_node_t *n, std::map &h) +static void get_exported(const env_node_t *n, std::map *h) { if (!n) return; @@ -1279,10 +1279,19 @@ static void get_exported(const env_node_t *n, std::map &h) { const wcstring &key = iter->first; const var_entry_t &val_entry = iter->second; - if (val_entry.exportv && (val_entry.val != ENV_NULL)) + + if (val_entry.exportv && val_entry.val != ENV_NULL) + { + // Export the variable + // Don't use std::map::insert here, since we need to overwrite existing + // values from previous scopes + (*h)[key] = val_entry.val; + } + else { - // Don't use std::map::insert here, since we need to overwrite existing values from previous scopes - h[key] = val_entry.val; + // We need to erase from the map if we are not exporting, + // since a lower scope may have exported. See #2132 + h->erase(key); } } } @@ -1333,7 +1342,7 @@ static void update_export_array_if_necessary(bool recalc) debug(4, L"env_export_arr() recalc"); - get_exported(top, vals); + get_exported(top, &vals); if (uvars()) { diff --git a/tests/test3.in b/tests/test3.in index 970741d1..fe20928c 100644 --- a/tests/test3.in +++ b/tests/test3.in @@ -227,6 +227,14 @@ else echo Test 16 fail end +# Test that shadowing with a non-exported variable works +set -gx __fish_test_env17 UNSHADOWED +env | sgrep __fish_test_env17 +function __fish_test_shadow + set -l __fish_test_env17 + env | sgrep __fish_test_env17 ; or echo SHADOWED +end +__fish_test_shadow # clear for other shells set -eU __fish_test_universal_variables_variable_foo diff --git a/tests/test3.out b/tests/test3.out index a6d5d3ac..806ea708 100644 --- a/tests/test3.out +++ b/tests/test3.out @@ -16,6 +16,8 @@ Test 15 pass Foo change detected Foo change detected Test 16 pass +__fish_test_env17=UNSHADOWED +SHADOWED Testing Universal Startup 1 1 -- cgit v1.2.3 From 5c6143d8e9a7e0090b402716cccdb5e2c849dbc3 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 13 Jun 2015 22:56:01 -0700 Subject: Use --remove instead of -e when erasing abbreviations from fish_config Updates fish_config to use the correct argument to abbr --- share/tools/web_config/webconfig.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index d65c86f8..c122f587 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -702,14 +702,14 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): return result def do_remove_abbreviation(self, abbreviation): - out, err = run_fish_cmd('abbr -e %s' % abbreviation['word']) + out, err = run_fish_cmd('abbr --remove %s' % abbreviation['word']) if out or err: return err else: return True def do_save_abbreviation(self, abbreviation): - out, err = run_fish_cmd('abbr -a \'%s %s\'' % (abbreviation['word'], abbreviation['phrase'])) + out, err = run_fish_cmd('abbr --add \'%s %s\'' % (abbreviation['word'], abbreviation['phrase'])) if err: return err else: -- cgit v1.2.3 From 7b34aaa432ef86f6f82c0ad828ff8804248e64df Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 13 Jun 2015 22:56:45 -0700 Subject: Tweak the styling of the abbreviation editor Removes the big white block of the input fields. --- share/tools/web_config/fishconfig.css | 16 ++++++++++++++-- share/tools/web_config/partials/abbreviations.html | 10 +++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/share/tools/web_config/fishconfig.css b/share/tools/web_config/fishconfig.css index f24f442e..bba26b41 100644 --- a/share/tools/web_config/fishconfig.css +++ b/share/tools/web_config/fishconfig.css @@ -29,6 +29,8 @@ body { border-right: none; padding-bottom: 15px; padding-top: 15px; + padding-left: 8px; + padding-right: 8px; font-size: 17pt; text-align: center; width: 15%; @@ -232,12 +234,22 @@ body { border-bottom: #444 dotted 1px; } - .abbreviation_actions { - width: 5em; +.abbreviation_actions { + width: 8em; text-align: right; border-bottom: #444 dotted 1px; } +.abbreviation_input { + background-color: #111; + border: solid 1px #777; + height: 1.5em; + color: white; + font: inherit; + padding: 3px; + margin: 0; +} + /* The CSS we apply when a table row is filtered */ .data_table_row_filtered { display: none; diff --git a/share/tools/web_config/partials/abbreviations.html b/share/tools/web_config/partials/abbreviations.html index e56281ef..382ebeee 100644 --- a/share/tools/web_config/partials/abbreviations.html +++ b/share/tools/web_config/partials/abbreviations.html @@ -5,17 +5,17 @@ - -- cgit v1.2.3 From 6fbb3c9976cc8fe0b9b501214d46b73a9951e4cb Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 14 Jun 2015 00:04:29 -0700 Subject: fish_config to select the proper tab when run with a tab name `fish_config abbr` should show "abbreviations" selected in the tab list. --- share/tools/web_config/js/controllers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/tools/web_config/js/controllers.js b/share/tools/web_config/js/controllers.js index 0ddfa83f..73985b7a 100644 --- a/share/tools/web_config/js/controllers.js +++ b/share/tools/web_config/js/controllers.js @@ -1,8 +1,8 @@ controllers = angular.module("controllers", []); controllers.controller("main", function($scope, $location) { - $scope.currentTab = "colors"; - + // substr(1) strips a leading slash + $scope.currentTab = $location.path().substr(1) || "colors"; $scope.changeView = function(view) { $location.path(view); $scope.currentTab = view; -- cgit v1.2.3 From 064ad7b9812b85192a5377923084cadee4da03d9 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Thu, 4 Jun 2015 13:31:48 -0700 Subject: Rework how the mode is reported in fish_vi_mode Add a new function fish_mode_prompt which (if it is defined) has its output prepended to the left prompt. Rather than replacing the prompt wholesale, make fish_vi_mode enable this function by setting a variable __fish_vi_mode. This enables vi mode to interoperate nicely with custom prompts. Users who want to change how the mode is reported can either redefine this function or erase it entirely. Fixes #1988. --- reader.cpp | 16 +++++++++++ share/functions/fish_mode_prompt.fish | 19 +++++++++++++ share/functions/fish_vi_mode.fish | 8 +++--- share/functions/fish_vi_prompt.fish | 51 ----------------------------------- 4 files changed, 40 insertions(+), 54 deletions(-) create mode 100644 share/functions/fish_mode_prompt.fish delete mode 100644 share/functions/fish_vi_prompt.fish diff --git a/reader.cpp b/reader.cpp index 4fdd6ceb..23f51a08 100644 --- a/reader.cpp +++ b/reader.cpp @@ -128,6 +128,10 @@ commence. #define RIGHT_PROMPT_FUNCTION_NAME L"fish_right_prompt" +/* The name of the function for getting the input mode indicator */ +#define MODE_PROMPT_FUNCTION_NAME L"fish_mode_prompt" + + /** The default title for the reader. This is used by reader_readline. */ @@ -997,6 +1001,18 @@ static void exec_prompt() { proc_push_interactive(0); + // Prepend any mode indicator to the left prompt (#1988) + if (function_exists(MODE_PROMPT_FUNCTION_NAME)) + { + wcstring_list_t mode_indicator_list; + exec_subshell(MODE_PROMPT_FUNCTION_NAME, mode_indicator_list, apply_exit_status); + // We do not support multiple lines in the mode indicator, so just concatenate all of them + for (size_t i = 0; i < mode_indicator_list.size(); i++) + { + data->left_prompt_buff += mode_indicator_list.at(i); + } + } + if (! data->left_prompt.empty()) { wcstring_list_t prompt_list; diff --git a/share/functions/fish_mode_prompt.fish b/share/functions/fish_mode_prompt.fish new file mode 100644 index 00000000..30521679 --- /dev/null +++ b/share/functions/fish_mode_prompt.fish @@ -0,0 +1,19 @@ +# The fish_mode_prompt function is prepended to the prompt +function fish_mode_prompt --description "Displays the current mode" + # Do nothing if not in vi mode + if set -q __fish_vi_mode + switch $fish_bind_mode + case default + set_color --bold --background red white + echo '[N]' + case insert + set_color --bold --background green white + echo '[I]' + case visual + set_color --bold --background magenta white + echo '[V]' + end + set_color normal + echo -n ' ' + end +end diff --git a/share/functions/fish_vi_mode.fish b/share/functions/fish_vi_mode.fish index e431d0e4..b4fbe63a 100644 --- a/share/functions/fish_vi_mode.fish +++ b/share/functions/fish_vi_mode.fish @@ -1,6 +1,8 @@ function fish_vi_mode - function fish_prompt - fish_vi_prompt - end + # Set the __fish_vi_mode variable + # This triggers fish_mode_prompt to output the mode indicator + set -g __fish_vi_mode 1 + + # Turn on vi keybindings set -g fish_key_bindings fish_vi_key_bindings end diff --git a/share/functions/fish_vi_prompt.fish b/share/functions/fish_vi_prompt.fish deleted file mode 100644 index 420ea3cf..00000000 --- a/share/functions/fish_vi_prompt.fish +++ /dev/null @@ -1,51 +0,0 @@ -function fish_vi_prompt_cm --description "Displays the current mode" - echo -n " " - switch $fish_bind_mode - case default - set_color --bold --background red white - echo "[N]" - case insert - set_color --bold --background green white - echo "[I]" - case visual - set_color --bold --background magenta white - echo "[V]" - end - set_color normal -end - -function fish_vi_prompt --description "Simple vi prompt" - - # Just calculate these once, to save a few cycles when displaying the prompt - if not set -q __fish_prompt_hostname - set -g __fish_prompt_hostname (hostname|cut -d . -f 1) - end - - if not set -q __fish_prompt_normal - set -g __fish_prompt_normal (set_color normal) - end - - switch $USER - - case root toor - - if not set -q __fish_prompt_cwd - if set -q fish_color_cwd_root - set -g __fish_prompt_cwd (set_color $fish_color_cwd_root) - else - set -g __fish_prompt_cwd (set_color $fish_color_cwd) - end - end - - echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" (fish_vi_prompt_cm) '# ' - - case '*' - - if not set -q __fish_prompt_cwd - set -g __fish_prompt_cwd (set_color $fish_color_cwd) - end - - echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' "$__fish_prompt_cwd" (prompt_pwd) "$__fish_prompt_normal" (fish_vi_prompt_cm) '> ' - - end -end -- cgit v1.2.3 From 781bbe217ae6d27584f20be7a0b3966b0761c05c Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 14 Jun 2015 14:08:10 -0700 Subject: Tweak and add tests for abbr 1. When run with no arguments, make abbr do the equivalent of `abbr --show` 2. Enable "implicit add", e.g. `abbr gco git checkout` 3. Teach `abbr --show` to not use quotes for simple cases 4. Teach abbr to output -- when the abbreviation has leading dashes Add some basic tests to abbr too. --- share/functions/abbr.fish | 38 ++++++++++++++++++++++++++++++------- share/tools/web_config/webconfig.py | 2 +- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/share/functions/abbr.fish b/share/functions/abbr.fish index dd67b898..87cf3184 100644 --- a/share/functions/abbr.fish +++ b/share/functions/abbr.fish @@ -1,9 +1,4 @@ function abbr --description "Manage abbreviations" - if not set -q argv[1] - __fish_print_help abbr - return 1 - end - # parse arguments set -l mode set -l mode_flag # the flag that was specified, for better errors @@ -56,6 +51,18 @@ function abbr --description "Manage abbreviations" printf ( _ "%s: option requires an argument -- %s\n" ) abbr $mode_flag >&2 return 1 end + + # If run with no options, treat it like --add if we have an argument, or + # --show if we do not have an argument + if test -z "$mode" + if set -q argv[1] + set mode 'add' + set mode_arg "$argv" + set -e argv + else + set mode 'show' + end + end # none of our modes want any excess arguments if set -q argv[1] @@ -106,7 +113,14 @@ function abbr --description "Manage abbreviations" for i in $fish_user_abbreviations # Disable newline splitting set -lx IFS '' - echo abbr -a \'(__fish_abbr_escape $i)\' + __fish_abbr_parse_entry $i key value + + # Check to see if either key or value has a leading dash + # If so, we need to write -- + set -l opt_double_dash '' + switch $key ; case '-*'; set opt_double_dash ' --'; end + switch $value ; case '-*'; set opt_double_dash ' --'; end + echo abbr$opt_double_dash (__fish_abbr_escape "$key") (__fish_abbr_escape "$value") end return 0 @@ -121,7 +135,17 @@ function abbr --description "Manage abbreviations" end function __fish_abbr_escape - echo $argv | sed -e s,\\\\,\\\\\\\\,g -e s,\',\\\\\',g + # Prettify the common case: if everything is alphanumeric, + # we do not need escapes. + # Do this by deleting alnum characters, and check if there's anything left. + # Note we need to preserve spaces, so spaces are not considered alnum + if test -z (echo -n "$argv" | tr -d '[:alnum:]_') + echo $argv + else + # Escape via single quotes + # printf is nice for stripping the newline that sed outputs + printf "'%s'" (echo -n $argv | sed -e s,\\\\,\\\\\\\\,g -e s,\',\\\\\',g) + end end function __fish_abbr_get_by_key diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index c122f587..359946ae 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -709,7 +709,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): return True def do_save_abbreviation(self, abbreviation): - out, err = run_fish_cmd('abbr --add \'%s %s\'' % (abbreviation['word'], abbreviation['phrase'])) + out, err = run_fish_cmd('abbr --add -- \'%s %s\'' % (abbreviation['word'], abbreviation['phrase'])) if err: return err else: -- cgit v1.2.3 From d79a72d7221ef23bd6a927d2f7f2553c0ce2dd8f Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 14 Jun 2015 14:13:57 -0700 Subject: Add abbreviation tests --- tests/abbr.err | 1 + tests/abbr.in | 33 +++++++++++++++++++++++++++++++++ tests/abbr.out | 8 ++++++++ tests/abbr.status | 1 + 4 files changed, 43 insertions(+) create mode 100644 tests/abbr.err create mode 100644 tests/abbr.in create mode 100644 tests/abbr.out create mode 100644 tests/abbr.status diff --git a/tests/abbr.err b/tests/abbr.err new file mode 100644 index 00000000..904a0fd4 --- /dev/null +++ b/tests/abbr.err @@ -0,0 +1 @@ +abbr: no such abbreviation 'NOT_AN_ABBR' diff --git a/tests/abbr.in b/tests/abbr.in new file mode 100644 index 00000000..69fdfb38 --- /dev/null +++ b/tests/abbr.in @@ -0,0 +1,33 @@ +# Test basic add and list +abbr __abbr1 alpha beta gamma +abbr | grep __abbr1 + +# Erasing one that doesn't exist should do nothing +abbr --erase NOT_AN_ABBR +abbr | grep __abbr1 + +# Adding existing one should be idempotent +abbr __abbr1 alpha beta gamma +abbr | grep __abbr1 + +# Replacing +abbr __abbr1 delta +abbr | grep __abbr1 + +# -s and --show tests +abbr -s | grep __abbr1 +abbr --show | grep __abbr1 + +# Test erasing +abbr -e __abbr1 +abbr | grep __abbr1 + +# Ensure we escape special characters on output +abbr '~__abbr2' '$xyz' +abbr | grep __abbr2 +abbr -e '~__abbr2' + +# Ensure we handle leading dashes in abbreviation names properly +abbr -- '--__abbr3' 'xyz' +abbr | grep __abbr3 +abbr -e '--__abbr3' diff --git a/tests/abbr.out b/tests/abbr.out new file mode 100644 index 00000000..b0a9d5ad --- /dev/null +++ b/tests/abbr.out @@ -0,0 +1,8 @@ +abbr __abbr1 'alpha beta gamma' +abbr __abbr1 'alpha beta gamma' +abbr __abbr1 'alpha beta gamma' +abbr __abbr1 delta +abbr __abbr1 delta +abbr __abbr1 delta +abbr '~__abbr2' '$xyz' +abbr -- '--__abbr3' xyz diff --git a/tests/abbr.status b/tests/abbr.status new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/tests/abbr.status @@ -0,0 +1 @@ +0 -- cgit v1.2.3 From ecb2da314214afde1afea6a1c943f26c3e5ada2d Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 20 Jun 2015 12:26:03 -0700 Subject: Fix wildcard expansion in directories without read permissions When performing wildcard expansion with a literal path segment, instead of enumerating the files in the directory, simply apply the path segment as if we found the directory and continue on. This enables us to expand strings that contain unreadable directory components (common with $HOME) and also improves performance, since we don't waste time enumerating directories unnecessarily. Adds a test too. Fixes #2099 --- tests/test5.in | 12 +++++++++ tests/test5.out | 1 + wildcard.cpp | 77 ++++++++++++++++++++++++++++++--------------------------- 3 files changed, 53 insertions(+), 37 deletions(-) diff --git a/tests/test5.in b/tests/test5.in index a3e2256c..1afc0cc7 100644 --- a/tests/test5.in +++ b/tests/test5.in @@ -23,3 +23,15 @@ switch $smurf case "?????" echo Test 3 pass end + +# Verify that we can do wildcard expansion when we +# don't have read access to some path components +# See #2099 +set -l where /tmp/fish_wildcard_permissions_test/noaccess/yesaccess +mkdir -p $where +chmod 300 (dirname $where) # no read permissions +mkdir -p $where +touch $where/alpha.txt $where/beta.txt $where/delta.txt +echo $where/* +chmod 700 (dirname $where) # so we can delete it +rm -rf /tmp/fish_wildcard_permissions_test diff --git a/tests/test5.out b/tests/test5.out index 66343bb8..bdee60aa 100644 --- a/tests/test5.out +++ b/tests/test5.out @@ -1,3 +1,4 @@ Test 1 pass Test 2 pass Test 3 pass +/tmp/fish_wildcard_permissions_test/noaccess/yesaccess/alpha.txt /tmp/fish_wildcard_permissions_test/noaccess/yesaccess/beta.txt /tmp/fish_wildcard_permissions_test/noaccess/yesaccess/delta.txt diff --git a/wildcard.cpp b/wildcard.cpp index eb29c4e6..305e75f4 100644 --- a/wildcard.cpp +++ b/wildcard.cpp @@ -772,19 +772,12 @@ static int wildcard_expand_internal(const wchar_t *wc, std::set &completion_set, std::set &visited_files) { - /* Variables for traversing a directory */ DIR *dir; /* The result returned */ int res = 0; - /* Variables for testing for presense of recursive wildcards */ - const wchar_t *wc_recursive; - bool is_recursive; - - /* Slightly mangled version of base_dir */ - const wchar_t *dir_string; // debug( 3, L"WILDCARD_EXPAND %ls in %ls", wc, base_dir ); @@ -800,45 +793,61 @@ static int wildcard_expand_internal(const wchar_t *wc, } const size_t base_dir_len = wcslen(base_dir); + const size_t wc_len = wcslen(wc); if (flags & ACCEPT_INCOMPLETE) { /* Avoid excessive number of returned matches for wc ending with a * */ - size_t len = wcslen(wc); - if (len > 0 && (wc[len-1]==ANY_STRING)) + if (wc_len > 0 && (wc[wc_len-1]==ANY_STRING)) { wchar_t * foo = wcsdup(wc); - foo[len-1]=0; + foo[wc_len-1]=0; int res = wildcard_expand_internal(foo, base_dir, flags, out, completion_set, visited_files); free(foo); return res; } } - /* Initialize various variables */ - - dir_string = (base_dir[0] == L'\0') ? L"." : base_dir; + /* Determine if we are the last segment */ + const wchar_t * const next_slash = wcschr(wc,L'/'); + const bool is_last_segment = (next_slash == NULL); + const size_t wc_segment_len = next_slash ? next_slash - wc : wc_len; + const wcstring wc_segment = wcstring(wc, wc_segment_len); + + /* Maybe this segment has no wildcards at all. If this is not the last segment, and it has no wildcards, then we don't need to match against the directory contents, and in fact we don't want to match since we may not be able to read it anyways (#2099). Don't even open the directory! */ + const bool segment_has_wildcards = wildcard_has(wc_segment, true /* internal, i.e. look for ANY_CHAR instead of ? */); + if (! segment_has_wildcards && ! is_last_segment) + { + wcstring new_base_dir = make_path(base_dir, wc_segment); + new_base_dir.push_back(L'/'); + + /* Skip multiple separators */ + assert(next_slash != NULL); + const wchar_t *new_wc = next_slash; + while (*new_wc==L'/') + { + new_wc++; + } + /* Early out! */ + return wildcard_expand_internal(new_wc, new_base_dir.c_str(), flags, out, completion_set, visited_files); + } + + /* Test for recursive match string in current segment */ + const bool is_recursive = (wc_segment.find(ANY_STRING_RECURSIVE) != wcstring::npos); + - if (!(dir = wopendir(dir_string))) + const wchar_t *base_dir_or_cwd = (base_dir[0] == L'\0') ? L"." : base_dir; + if (!(dir = wopendir(base_dir_or_cwd))) { return 0; } - - /* Points to the end of the current wildcard segment */ - const wchar_t * const wc_end = wcschr(wc,L'/'); - - /* - Test for recursive match string in current segment - */ - wc_recursive = wcschr(wc, ANY_STRING_RECURSIVE); - is_recursive = (wc_recursive && (!wc_end || wc_recursive < wc_end)); - + /* Is this segment of the wildcard the last? */ - if (!wc_end) + if (is_last_segment) { /* Wildcard segment is the last segment, @@ -926,7 +935,7 @@ static int wildcard_expand_internal(const wchar_t *wc, } } - if (wc_end || is_recursive) + if ((! is_last_segment) || is_recursive) { /* Wilcard segment is not the last segment. Recursively call @@ -939,12 +948,6 @@ static int wildcard_expand_internal(const wchar_t *wc, */ rewinddir(dir); - /* - wc_str is the part of the wildcarded string from the - beginning to the first slash - */ - const wcstring wc_str = wcstring(wc, wc_end ? wc_end - wc : wcslen(wc)); - /* new_dir is a scratch area containing the full path to a file/directory we are iterating over */ wcstring new_dir = base_dir; @@ -955,8 +958,8 @@ static int wildcard_expand_internal(const wchar_t *wc, Test if the file/directory name matches the whole wildcard element, i.e. regular matching. */ - int whole_match = wildcard_match(name_str, wc_str, true /* ignore leading dots */); - int partial_match = 0; + bool whole_match = wildcard_match(name_str, wc_segment, true /* ignore leading dots */); + bool partial_match = false; /* If we are doing recursive matching, also check if this @@ -999,11 +1002,11 @@ static int wildcard_expand_internal(const wchar_t *wc, if (whole_match) { const wchar_t *new_wc = L""; - if (wc_end) + if (next_slash) { - new_wc=wc_end+1; + new_wc=next_slash+1; /* - Accept multiple '/' as a single direcotry separator + Accept multiple '/' as a single directory separator */ while (*new_wc==L'/') { -- cgit v1.2.3 From 322a6118720b060638dbb72481ea0c996fb9334e Mon Sep 17 00:00:00 2001 From: David Adam Date: Sun, 28 Jun 2015 18:11:48 +0800 Subject: Bump version for 2.2.0 --- fish.xcodeproj/project.pbxproj | 6 +++--- osx/config.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fish.xcodeproj/project.pbxproj b/fish.xcodeproj/project.pbxproj index 037563bc..ae1612db 100644 --- a/fish.xcodeproj/project.pbxproj +++ b/fish.xcodeproj/project.pbxproj @@ -1327,7 +1327,7 @@ "SYSCONFDIR=L\\\"/usr/local/etc\\\"", "BINDIR=L\\\"/usr/local/bin\\\"", "DOCDIR=L\\\"/usr/local/share/doc\\\"", - "FISH_BUILD_VERSION=\\\"2.2b1\\\"", + "FISH_BUILD_VERSION=\\\"2.2.0\\\"", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -1455,7 +1455,7 @@ "SYSCONFDIR=L\\\"/usr/local/etc\\\"", "BINDIR=L\\\"/usr/local/bin\\\"", "DOCDIR=L\\\"/usr/local/share/doc\\\"", - "FISH_BUILD_VERSION=\\\"2.2b1\\\"", + "FISH_BUILD_VERSION=\\\"2.2.0\\\"", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -1483,7 +1483,7 @@ "SYSCONFDIR=L\\\"/usr/local/etc\\\"", "BINDIR=L\\\"/usr/local/bin\\\"", "DOCDIR=L\\\"/usr/local/share/doc\\\"", - "FISH_BUILD_VERSION=\\\"2.2b1\\\"", + "FISH_BUILD_VERSION=\\\"2.2.0\\\"", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; diff --git a/osx/config.h b/osx/config.h index a5b0df28..e31de669 100644 --- a/osx/config.h +++ b/osx/config.h @@ -222,7 +222,7 @@ #define PACKAGE_NAME "fish" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "fish 2.2b1" +#define PACKAGE_STRING "fish 2.2.0" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "fish" @@ -231,7 +231,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "2.2b1" +#define PACKAGE_VERSION "2.2.0" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 -- cgit v1.2.3 From e60db8075ca81be9ddbff4d3a3577bcafab51658 Mon Sep 17 00:00:00 2001 From: David Adam Date: Fri, 3 Jul 2015 15:31:03 +0800 Subject: Open universal variable lock file read/write and ignore errors Closes #2149. --- env_universal_common.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/env_universal_common.cpp b/env_universal_common.cpp index f90cc82b..b493de21 100644 --- a/env_universal_common.cpp +++ b/env_universal_common.cpp @@ -698,7 +698,7 @@ bool env_universal_t::open_and_acquire_lock(const wcstring &path, int *out_fd) */ int result_fd = -1; bool needs_lock = true; - int flags = O_RDONLY | O_CREAT; + int flags = O_RDWR | O_CREAT; #ifdef O_EXLOCK flags |= O_EXLOCK; needs_lock = false; @@ -741,8 +741,7 @@ bool env_universal_t::open_and_acquire_lock(const wcstring &path, int *out_fd) /* error */ if (errno != EINTR) { - int err = errno; - report_error(err, L"Unable to lock universal variable file '%ls'", path.c_str()); + /* Do nothing per #2149 */ break; } } -- cgit v1.2.3 From 8ca21767fe96f15d863164c964522baad36be474 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 3 Jul 2015 12:35:53 -0700 Subject: Improve discussion of how to set PATH in the tutorial Also fix a few broken anchors --- doc_src/tutorial.hdr | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/doc_src/tutorial.hdr b/doc_src/tutorial.hdr index fe624d95..772c0259 100644 --- a/doc_src/tutorial.hdr +++ b/doc_src/tutorial.hdr @@ -27,7 +27,7 @@ - $PATH - Startup - Autoloading Functions -- Ready for more? +- Ready for more? \htmlonly[block] @@ -510,18 +510,19 @@ Multiple lines are OK. Colors can be set via `set_color`, passing it named ANSI You can choose among some sample prompts by running `fish_config prompt`. `fish` also supports RPROMPT through `fish_right_prompt`. -\section tut-path $PATH +\section tut_path $PATH -`$PATH` is an environment variable containing the directories in which `fish` searches for commands. Instead of separating entries with a colon, $PATH is a list. You can modify $PATH in a few ways: +`$PATH` is an environment variable containing the directories in which `fish` searches for commands. Unlike other shells, $PATH is a [list](#tut_lists), not a colon-delimited string. --# By modifying the `$fish_user_paths` variable, which is automatically appended to `$PATH`. For example, to permanently add `/usr/local/bin` to your `$PATH`, you could write: +You can set PATH directly in fish.config, like you would do in other shells. See [this example](#path_example). + +A faster way is to modify the `$fish_user_paths` [universal variable](#tut_universal), which is automatically prepended to `$PATH`. For example, to permanently add `/usr/local/bin` to your `$PATH`, you could write: \fish{cli-dark} >_ set -U fish_user_paths $fish_user_paths /usr/local/bin \endfish --# Directly in config.fish (see below). - +You just run this once at the command line, and it will affect the current session and all future instances too. (Note: you should NOT add this line to `fish.config`. If you do, the variable will get longer each time you run fish!) \section tut_startup Startup (Where's .bashrc?) @@ -529,6 +530,7 @@ You can choose among some sample prompts by running `fish_config prompt`. `fish` It is possible to directly create functions and variables in `config.fish` file, using the commands shown above. For example: + \fish{cli-dark} >_ cat ~/.config/fish/config.fish @@ -541,7 +543,7 @@ end However, it is more common and efficient to use autoloading functions and universal variables. -\section tut-autoload Autoloading Functions +\section tut_autoload Autoloading Functions When `fish` encounters a command, it attempts to autoload a function for that command, by looking for a file with the name of that command in `~/.config/fish/functions/`. @@ -565,7 +567,7 @@ end See the documentation for funced and funcsave for ways to create these files automatically. -\section tut-universal Universal Variables +\section tut_universal Universal Variables A universal variable is a variable whose value is shared across all instances of `fish`, now and in the future – even after a reboot. You can make a variable universal with `set -U`: @@ -580,7 +582,7 @@ Now in another shell: vim \endfish -\section tut-more Ready for more? +\section tut_more Ready for more? If you want to learn more about fish, there is lots of detailed documentation, an official mailing list, the IRC channel \#fish on `irc.oftc.net`, and the github page. -- cgit v1.2.3 From e752ac3035e6438303d79845637a4a2eaea4ff02 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 3 Jul 2015 12:46:40 -0700 Subject: Further tweak the language about setting PATH in the tutorial --- doc_src/tutorial.hdr | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/doc_src/tutorial.hdr b/doc_src/tutorial.hdr index 772c0259..7cad5cb9 100644 --- a/doc_src/tutorial.hdr +++ b/doc_src/tutorial.hdr @@ -514,15 +514,21 @@ You can choose among some sample prompts by running `fish_config prompt`. `fish` `$PATH` is an environment variable containing the directories in which `fish` searches for commands. Unlike other shells, $PATH is a [list](#tut_lists), not a colon-delimited string. -You can set PATH directly in fish.config, like you would do in other shells. See [this example](#path_example). +To prepend to `$PATH`, you can write: + +\fish{cli-dark} +>_ set PATH /new/path $PATH +\endfish + +You can do so directly in `fish.config`, like you might do in other shells with `.profile`. See [this example](#path_example). A faster way is to modify the `$fish_user_paths` [universal variable](#tut_universal), which is automatically prepended to `$PATH`. For example, to permanently add `/usr/local/bin` to your `$PATH`, you could write: \fish{cli-dark} ->_ set -U fish_user_paths $fish_user_paths /usr/local/bin +>_ set -U fish_user_paths /usr/local/bin $fish_user_paths \endfish -You just run this once at the command line, and it will affect the current session and all future instances too. (Note: you should NOT add this line to `fish.config`. If you do, the variable will get longer each time you run fish!) +The advantage is that you don't have to go mucking around in files: just run this once at the command line, and it will affect the current session and all future instances too. (Note: you should NOT add this line to `fish.config`. If you do, the variable will get longer each time you run fish!) \section tut_startup Startup (Where's .bashrc?) -- cgit v1.2.3
+ {{ abbreviation.word }} - + {{ abbreviation.phrase }} - + - Save - Delete + Save + Delete