Restore %self to refer to the fish pid

This brings back the %self argument. Like the original %self it only expands
if the argument is literally %self.
This commit is contained in:
ridiculousfish
2018-10-10 14:26:29 -07:00
parent 6df29b2fd1
commit d73c487d60
8 changed files with 44 additions and 5 deletions

View File

@@ -1040,6 +1040,7 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
case L'|':
case L';':
case L'"':
case L'%':
case L'~': {
bool char_is_normal = (c == L'~' && no_tilde) || (c == L'^' && no_caret) ||
(c == L'?' && no_qmark);
@@ -1398,6 +1399,17 @@ static bool unescape_string_internal(const wchar_t *const input, const size_t in
}
break;
}
case L'%': {
// Note that this only recognizes %self if the string is literally %self.
// %self/foo will NOT match this.
if (unescape_special && input_position == 0 &&
!wcscmp(input, PROCESS_EXPAND_SELF_STR)) {
to_append_or_none = PROCESS_EXPAND_SELF;
input_position +=
wcslen(PROCESS_EXPAND_SELF_STR) - 1; // skip over 'self' part.
}
break;
}
case L'*': {
if (unescape_special) {
// In general, this is ANY_STRING. But as a hack, if the last appended char