mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Merge branch 'master' into ast
This commit is contained in:
commit
e8d6c96c1e
10
Makefile.in
10
Makefile.in
@ -552,6 +552,8 @@ install-force: all install-translations
|
|||||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/man/man1
|
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/man/man1
|
||||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools
|
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools
|
||||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config
|
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config
|
||||||
|
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config/js
|
||||||
|
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config/partials
|
||||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config/sample_prompts
|
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config/sample_prompts
|
||||||
$(INSTALL) -m 644 etc/config.fish $(DESTDIR)$(sysconfdir)/fish/
|
$(INSTALL) -m 644 etc/config.fish $(DESTDIR)$(sysconfdir)/fish/
|
||||||
$(INSTALL) -m 644 share/config.fish $(DESTDIR)$(datadir)/fish/
|
$(INSTALL) -m 644 share/config.fish $(DESTDIR)$(datadir)/fish/
|
||||||
@ -575,6 +577,14 @@ install-force: all install-translations
|
|||||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/tools/web_config/; \
|
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/tools/web_config/; \
|
||||||
true; \
|
true; \
|
||||||
done;
|
done;
|
||||||
|
for i in share/tools/web_config/js/*; do\
|
||||||
|
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/tools/web_config/js/; \
|
||||||
|
true; \
|
||||||
|
done;
|
||||||
|
for i in share/tools/web_config/partials/*; do\
|
||||||
|
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/tools/web_config/partials/; \
|
||||||
|
true; \
|
||||||
|
done;
|
||||||
for i in share/tools/web_config/sample_prompts/*.fish; do\
|
for i in share/tools/web_config/sample_prompts/*.fish; do\
|
||||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/tools/web_config/sample_prompts/; \
|
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/tools/web_config/sample_prompts/; \
|
||||||
true; \
|
true; \
|
||||||
|
132
common.cpp
132
common.cpp
@ -917,61 +917,28 @@ void write_screen(const wcstring &msg, wcstring &buff)
|
|||||||
buff.push_back(L'\n');
|
buff.push_back(L'\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* Escape a string, storing the result in out_str */
|
||||||
Perform string escaping of a strinng by only quoting it. Assumes
|
static void escape_string_internal(const wchar_t *orig_in, size_t in_len, wcstring *out_str, escape_flags_t flags)
|
||||||
the string has already been checked for characters that can not be
|
|
||||||
escaped this way.
|
|
||||||
*/
|
|
||||||
static wchar_t *escape_simple(const wchar_t *in)
|
|
||||||
{
|
{
|
||||||
wchar_t *out;
|
assert(orig_in != NULL);
|
||||||
size_t len = wcslen(in);
|
|
||||||
out = (wchar_t *)malloc(sizeof(wchar_t)*(len+3));
|
|
||||||
if (!out)
|
|
||||||
DIE_MEM();
|
|
||||||
|
|
||||||
out[0] = L'\'';
|
|
||||||
wcscpy(&out[1], in);
|
|
||||||
out[len+1]=L'\'';
|
|
||||||
out[len+2]=0;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
wchar_t *escape(const wchar_t *in_orig, escape_flags_t flags)
|
|
||||||
{
|
|
||||||
const wchar_t *in = in_orig;
|
|
||||||
|
|
||||||
|
const wchar_t *in = orig_in;
|
||||||
bool escape_all = !!(flags & ESCAPE_ALL);
|
bool escape_all = !!(flags & ESCAPE_ALL);
|
||||||
bool no_quoted = !!(flags & ESCAPE_NO_QUOTED);
|
bool no_quoted = !!(flags & ESCAPE_NO_QUOTED);
|
||||||
bool no_tilde = !!(flags & ESCAPE_NO_TILDE);
|
bool no_tilde = !!(flags & ESCAPE_NO_TILDE);
|
||||||
|
|
||||||
wchar_t *out;
|
|
||||||
wchar_t *pos;
|
|
||||||
|
|
||||||
int need_escape=0;
|
int need_escape=0;
|
||||||
int need_complex_escape=0;
|
int need_complex_escape=0;
|
||||||
|
|
||||||
if (!in)
|
/* Avoid dereferencing all over the place */
|
||||||
|
wcstring &out = *out_str;
|
||||||
|
|
||||||
|
if (!no_quoted && in_len == 0)
|
||||||
{
|
{
|
||||||
debug(0, L"%s called with null input", __func__);
|
out.assign(L"''");
|
||||||
FATAL_EXIT();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!no_quoted && (wcslen(in) == 0))
|
|
||||||
{
|
|
||||||
out = wcsdup(L"''");
|
|
||||||
if (!out)
|
|
||||||
DIE_MEM();
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
out = (wchar_t *)malloc(sizeof(wchar_t)*(wcslen(in)*4 + 1));
|
|
||||||
pos = out;
|
|
||||||
|
|
||||||
if (!out)
|
|
||||||
DIE_MEM();
|
|
||||||
|
|
||||||
while (*in != 0)
|
while (*in != 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -981,14 +948,14 @@ wchar_t *escape(const wchar_t *in_orig, escape_flags_t flags)
|
|||||||
int val = *in - ENCODE_DIRECT_BASE;
|
int val = *in - ENCODE_DIRECT_BASE;
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
*(pos++) = L'\\';
|
out += L'\\';
|
||||||
*(pos++) = L'X';
|
out += L'X';
|
||||||
|
|
||||||
tmp = val/16;
|
tmp = val/16;
|
||||||
*pos++ = tmp > 9? L'a'+(tmp-10):L'0'+tmp;
|
out += tmp > 9? L'a'+(tmp-10):L'0'+tmp;
|
||||||
|
|
||||||
tmp = val%16;
|
tmp = val%16;
|
||||||
*pos++ = tmp > 9? L'a'+(tmp-10):L'0'+tmp;
|
out += tmp > 9? L'a'+(tmp-10):L'0'+tmp;
|
||||||
need_escape=need_complex_escape=1;
|
need_escape=need_complex_escape=1;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -998,32 +965,32 @@ wchar_t *escape(const wchar_t *in_orig, escape_flags_t flags)
|
|||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case L'\t':
|
case L'\t':
|
||||||
*(pos++) = L'\\';
|
out += L'\\';
|
||||||
*(pos++) = L't';
|
out += L't';
|
||||||
need_escape=need_complex_escape=1;
|
need_escape=need_complex_escape=1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L'\n':
|
case L'\n':
|
||||||
*(pos++) = L'\\';
|
out += L'\\';
|
||||||
*(pos++) = L'n';
|
out += L'n';
|
||||||
need_escape=need_complex_escape=1;
|
need_escape=need_complex_escape=1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L'\b':
|
case L'\b':
|
||||||
*(pos++) = L'\\';
|
out += L'\\';
|
||||||
*(pos++) = L'b';
|
out += L'b';
|
||||||
need_escape=need_complex_escape=1;
|
need_escape=need_complex_escape=1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L'\r':
|
case L'\r':
|
||||||
*(pos++) = L'\\';
|
out += L'\\';
|
||||||
*(pos++) = L'r';
|
out += L'r';
|
||||||
need_escape=need_complex_escape=1;
|
need_escape=need_complex_escape=1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L'\x1b':
|
case L'\x1b':
|
||||||
*(pos++) = L'\\';
|
out += L'\\';
|
||||||
*(pos++) = L'e';
|
out += L'e';
|
||||||
need_escape=need_complex_escape=1;
|
need_escape=need_complex_escape=1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1033,8 +1000,8 @@ wchar_t *escape(const wchar_t *in_orig, escape_flags_t flags)
|
|||||||
{
|
{
|
||||||
need_escape=need_complex_escape=1;
|
need_escape=need_complex_escape=1;
|
||||||
if (escape_all)
|
if (escape_all)
|
||||||
*pos++ = L'\\';
|
out += L'\\';
|
||||||
*pos++ = *in;
|
out += *in;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1063,9 +1030,9 @@ wchar_t *escape(const wchar_t *in_orig, escape_flags_t flags)
|
|||||||
{
|
{
|
||||||
need_escape=1;
|
need_escape=1;
|
||||||
if (escape_all)
|
if (escape_all)
|
||||||
*pos++ = L'\\';
|
out += L'\\';
|
||||||
}
|
}
|
||||||
*pos++ = *in;
|
out += *in;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1075,9 +1042,9 @@ wchar_t *escape(const wchar_t *in_orig, escape_flags_t flags)
|
|||||||
{
|
{
|
||||||
if (*in <27 && *in > 0)
|
if (*in <27 && *in > 0)
|
||||||
{
|
{
|
||||||
*(pos++) = L'\\';
|
out += L'\\';
|
||||||
*(pos++) = L'c';
|
out += L'c';
|
||||||
*(pos++) = L'a' + *in -1;
|
out += L'a' + *in -1;
|
||||||
|
|
||||||
need_escape=need_complex_escape=1;
|
need_escape=need_complex_escape=1;
|
||||||
break;
|
break;
|
||||||
@ -1086,15 +1053,15 @@ wchar_t *escape(const wchar_t *in_orig, escape_flags_t flags)
|
|||||||
|
|
||||||
|
|
||||||
int tmp = (*in)%16;
|
int tmp = (*in)%16;
|
||||||
*pos++ = L'\\';
|
out += L'\\';
|
||||||
*pos++ = L'x';
|
out += L'x';
|
||||||
*pos++ = ((*in>15)? L'1' : L'0');
|
out += ((*in>15)? L'1' : L'0');
|
||||||
*pos++ = tmp > 9? L'a'+(tmp-10):L'0'+tmp;
|
out += tmp > 9? L'a'+(tmp-10):L'0'+tmp;
|
||||||
need_escape=need_complex_escape=1;
|
need_escape=need_complex_escape=1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*pos++ = *in;
|
out += *in;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1103,7 +1070,6 @@ wchar_t *escape(const wchar_t *in_orig, escape_flags_t flags)
|
|||||||
|
|
||||||
in++;
|
in++;
|
||||||
}
|
}
|
||||||
*pos = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Use quoted escaping if possible, since most people find it
|
Use quoted escaping if possible, since most people find it
|
||||||
@ -1111,18 +1077,32 @@ wchar_t *escape(const wchar_t *in_orig, escape_flags_t flags)
|
|||||||
*/
|
*/
|
||||||
if (!no_quoted && need_escape && !need_complex_escape && escape_all)
|
if (!no_quoted && need_escape && !need_complex_escape && escape_all)
|
||||||
{
|
{
|
||||||
free(out);
|
wchar_t single_quote = L'\'';
|
||||||
out = escape_simple(in_orig);
|
out.clear();
|
||||||
|
out.reserve(2 + in_len);
|
||||||
|
out.push_back(single_quote);
|
||||||
|
out.append(orig_in, in_len);
|
||||||
|
out.push_back(single_quote);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t *escape(const wchar_t *in, escape_flags_t flags)
|
||||||
|
{
|
||||||
|
if (!in)
|
||||||
|
{
|
||||||
|
debug(0, L"%s called with null input", __func__);
|
||||||
|
FATAL_EXIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
wcstring tmp;
|
||||||
|
escape_string_internal(in, wcslen(in), &tmp, flags);
|
||||||
|
return wcsdup(tmp.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
wcstring escape_string(const wcstring &in, escape_flags_t flags)
|
wcstring escape_string(const wcstring &in, escape_flags_t flags)
|
||||||
{
|
{
|
||||||
wchar_t *tmp = escape(in.c_str(), flags);
|
wcstring result;
|
||||||
wcstring result(tmp);
|
escape_string_internal(in.c_str(), in.size(), &result, flags);
|
||||||
free(tmp);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ lesson.pdf
|
|||||||
/var/run/sntp.log
|
/var/run/sntp.log
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>If that directory traversal is taking a long time, you can control-C out of it.
|
<p>If that directory traversal is taking a long time, you can Control-C out of it.
|
||||||
|
|
||||||
<h2 id="tut_pipes_and_redirections">Pipes and Redirections</h2>
|
<h2 id="tut_pipes_and_redirections">Pipes and Redirections</h2>
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ You can iterate over a list (or a slice) with a <i>for loop</i>:
|
|||||||
> <b>for</b> <i>val</i> <b>in</b> <i>$PATH</i>
|
> <b>for</b> <i>val</i> <b>in</b> <i>$PATH</i>
|
||||||
<b>echo</b> <i>"entry: $val"</i>
|
<b>echo</b> <i>"entry: $val"</i>
|
||||||
<b>end</b>
|
<b>end</b>
|
||||||
entry: usr/bin/
|
entry: /usr/bin/
|
||||||
entry: /bin
|
entry: /bin
|
||||||
entry: /usr/sbin
|
entry: /usr/sbin
|
||||||
entry: /sbin
|
entry: /sbin
|
||||||
|
@ -89,6 +89,9 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis
|
|||||||
bind \e\[1\;9B history-token-search-forward # iTerm2
|
bind \e\[1\;9B history-token-search-forward # iTerm2
|
||||||
bind \e\[1\;9C forward-word #iTerm2
|
bind \e\[1\;9C forward-word #iTerm2
|
||||||
bind \e\[1\;9D backward-word #iTerm2
|
bind \e\[1\;9D backward-word #iTerm2
|
||||||
|
# Bash compatibility
|
||||||
|
# https://github.com/fish-shell/fish-shell/issues/89
|
||||||
|
bind \e. history-token-search-backward
|
||||||
bind \ed forward-kill-word
|
bind \ed forward-kill-word
|
||||||
bind -k ppage beginning-of-history
|
bind -k ppage beginning-of-history
|
||||||
bind -k npage end-of-history
|
bind -k npage end-of-history
|
||||||
|
Loading…
x
Reference in New Issue
Block a user