mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 11:59:27 +08:00
Reformat
This commit is contained in:
parent
e30f661867
commit
2e55e34544
|
@ -13,6 +13,7 @@ import re
|
|||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
try:
|
||||
from itertools import zip_longest
|
||||
except ImportError:
|
||||
|
@ -20,7 +21,7 @@ except ImportError:
|
|||
from difflib import SequenceMatcher
|
||||
|
||||
# Directives can occur at the beginning of a line, or anywhere in a line that does not start with #.
|
||||
COMMENT_RE = r'^(?:[^#].*)?#\s*'
|
||||
COMMENT_RE = r"^(?:[^#].*)?#\s*"
|
||||
|
||||
# A regex showing how to run the file.
|
||||
RUN_RE = re.compile(COMMENT_RE + r"RUN:\s+(.*)\n")
|
||||
|
@ -139,6 +140,7 @@ class Line(object):
|
|||
ret = ret.replace("{", "{{").replace("}", "}}")
|
||||
return ret
|
||||
|
||||
|
||||
class RunCmd(object):
|
||||
"""A command to run on a given Checker.
|
||||
|
||||
|
@ -215,10 +217,16 @@ class TestFailure(object):
|
|||
"",
|
||||
]
|
||||
if self.error_annotation_lines:
|
||||
fields["error_annotation"] = " ".join([x.text for x in self.error_annotation_lines])
|
||||
fields["error_annotation_lineno"] = str(self.error_annotation_lines[0].number)
|
||||
fields["error_annotation"] = " ".join(
|
||||
[x.text for x in self.error_annotation_lines]
|
||||
)
|
||||
fields["error_annotation_lineno"] = str(
|
||||
self.error_annotation_lines[0].number
|
||||
)
|
||||
if len(self.error_annotation_lines) > 1:
|
||||
fields["error_annotation_lineno"] += ":" + str(self.error_annotation_lines[-1].number)
|
||||
fields["error_annotation_lineno"] += ":" + str(
|
||||
self.error_annotation_lines[-1].number
|
||||
)
|
||||
fmtstrs += [
|
||||
" additional output on stderr:{error_annotation_lineno}:",
|
||||
" {BOLD}{error_annotation}{RESET}",
|
||||
|
@ -230,13 +238,18 @@ class TestFailure(object):
|
|||
for d in self.diff.get_grouped_opcodes():
|
||||
for op, alo, ahi, blo, bhi in d:
|
||||
color = "{BOLD}"
|
||||
if op == 'replace' or op == 'delete':
|
||||
if op == "replace" or op == "delete":
|
||||
color = "{RED}"
|
||||
# We got a new chunk, so we print a marker.
|
||||
if alo > lasthi:
|
||||
fmtstrs += [
|
||||
" [...] from line " + str(self.checks[blo].line.number)
|
||||
+ " (" + self.lines[alo].file + ":" + str(self.lines[alo].number) + "):"
|
||||
" [...] from line "
|
||||
+ str(self.checks[blo].line.number)
|
||||
+ " ("
|
||||
+ self.lines[alo].file
|
||||
+ ":"
|
||||
+ str(self.lines[alo].number)
|
||||
+ "):"
|
||||
]
|
||||
lasthi = ahi
|
||||
|
||||
|
@ -244,17 +257,41 @@ class TestFailure(object):
|
|||
lastcheck = False
|
||||
for a, b in zip_longest(self.lines[alo:ahi], self.checks[blo:bhi]):
|
||||
# Clean up strings for use in a format string - double up the curlies.
|
||||
astr = color + a.escaped_text(for_formatting=True) + "{RESET}" if a else ""
|
||||
astr = (
|
||||
color + a.escaped_text(for_formatting=True) + "{RESET}"
|
||||
if a
|
||||
else ""
|
||||
)
|
||||
if b:
|
||||
bstr = "'{BLUE}" + b.line.escaped_text(for_formatting=True) + "{RESET}'" + " on line " + str(b.line.number)
|
||||
bstr = (
|
||||
"'{BLUE}"
|
||||
+ b.line.escaped_text(for_formatting=True)
|
||||
+ "{RESET}'"
|
||||
+ " on line "
|
||||
+ str(b.line.number)
|
||||
)
|
||||
lastcheckline = b.line.number
|
||||
|
||||
if op == 'equal':
|
||||
if op == "equal":
|
||||
fmtstrs += [" " + astr]
|
||||
elif b and a:
|
||||
fmtstrs += [" " + astr + " <= does not match " + b.type + " " + bstr]
|
||||
fmtstrs += [
|
||||
" "
|
||||
+ astr
|
||||
+ " <= does not match "
|
||||
+ b.type
|
||||
+ " "
|
||||
+ bstr
|
||||
]
|
||||
elif b:
|
||||
fmtstrs += [" " + astr + " <= nothing to match " + b.type + " " + bstr]
|
||||
fmtstrs += [
|
||||
" "
|
||||
+ astr
|
||||
+ " <= nothing to match "
|
||||
+ b.type
|
||||
+ " "
|
||||
+ bstr
|
||||
]
|
||||
elif not b:
|
||||
string = " " + astr
|
||||
if bhi == len(self.checks):
|
||||
|
@ -262,7 +299,10 @@ class TestFailure(object):
|
|||
string += " <= no more checks"
|
||||
lastcheck = True
|
||||
elif lastcheckline is not None:
|
||||
string += " <= no check matches this, previous check on line " + str(lastcheckline)
|
||||
string += (
|
||||
" <= no check matches this, previous check on line "
|
||||
+ str(lastcheckline)
|
||||
)
|
||||
else:
|
||||
string += " <= no check matches"
|
||||
fmtstrs.append(string)
|
||||
|
@ -368,11 +408,22 @@ class TestRun(object):
|
|||
# If there's a mismatch or still lines or checkers, we have a failure.
|
||||
# Otherwise it's success.
|
||||
if mismatches:
|
||||
return TestFailure(mismatches[0][0], mismatches[0][1], self, diff=diff, lines=usedlines, checks=usedchecks)
|
||||
return TestFailure(
|
||||
mismatches[0][0],
|
||||
mismatches[0][1],
|
||||
self,
|
||||
diff=diff,
|
||||
lines=usedlines,
|
||||
checks=usedchecks,
|
||||
)
|
||||
elif lineq:
|
||||
return TestFailure(lineq[-1], None, self, diff=diff, lines=usedlines, checks=usedchecks)
|
||||
return TestFailure(
|
||||
lineq[-1], None, self, diff=diff, lines=usedlines, checks=usedchecks
|
||||
)
|
||||
elif checkq:
|
||||
return TestFailure(None, checkq[-1], self, diff=diff, lines=usedlines, checks=usedchecks)
|
||||
return TestFailure(
|
||||
None, checkq[-1], self, diff=diff, lines=usedlines, checks=usedchecks
|
||||
)
|
||||
else:
|
||||
# Success!
|
||||
return None
|
||||
|
|
|
@ -196,7 +196,13 @@ man_pages = [
|
|||
("tutorial", "fish-tutorial", "fish-shell tutorial", [author], 1),
|
||||
("CHANGELOG", "fish-changelog", "fish-shell changelog", [author], 1),
|
||||
("completions", "fish-completions", "Writing fish completions", [author], 1),
|
||||
("fish_for_bash_users", "fish-for-bash-users", "A quick fish primer for those coming from bash", [author], 1),
|
||||
(
|
||||
"fish_for_bash_users",
|
||||
"fish-for-bash-users",
|
||||
"A quick fish primer for those coming from bash",
|
||||
[author],
|
||||
1,
|
||||
),
|
||||
("faq", "fish-faq", "fish-shell faq", [author], 1),
|
||||
]
|
||||
for path in sorted(glob.glob("cmds/*")):
|
||||
|
|
|
@ -3,10 +3,9 @@ import os
|
|||
|
||||
def setup(app):
|
||||
current_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
app.add_html_theme(
|
||||
'python_docs_theme', current_dir)
|
||||
app.add_html_theme("python_docs_theme", current_dir)
|
||||
|
||||
return {
|
||||
'parallel_read_safe': True,
|
||||
'parallel_write_safe': True,
|
||||
"parallel_read_safe": True,
|
||||
"parallel_write_safe": True,
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ end
|
|||
|
||||
function __fish_ffmpeg_tunes
|
||||
set -l cmdline (commandline)
|
||||
if string match -req '264'
|
||||
if string match -req 264
|
||||
printf "%s\n" film animation grain stillimage fastdecode zerolatency psnr ssim
|
||||
end
|
||||
if string match -req '265|hevc'
|
||||
|
@ -110,7 +110,7 @@ function __fish_ffmpeg_crfs
|
|||
end
|
||||
|
||||
function __fish_ffmpeg_profile
|
||||
if string match -req '264'
|
||||
if string match -req 264
|
||||
printf "%s\n" baseline main high
|
||||
end
|
||||
if string match -req '265|hevc'
|
||||
|
@ -204,7 +204,7 @@ complete -c ffmpeg -s b -o "b:v" -d "Video bitrate"
|
|||
complete -c ffmpeg -o dn -d "Disable data"
|
||||
# Advanced video options
|
||||
complete -c ffmpeg -o pix_fmt
|
||||
__fish_ffmpeg_complete_regex "-pix_fmt" "(__fish_ffmpeg_pix_fmts)"
|
||||
__fish_ffmpeg_complete_regex -pix_fmt "(__fish_ffmpeg_pix_fmts)"
|
||||
|
||||
# Audio options
|
||||
complete -c ffmpeg -o aframes -d "Set the number of audio frames to output"
|
||||
|
@ -231,11 +231,11 @@ complete -c ffmpeg -o spre -d "Set the subtitle options to the indicated preset"
|
|||
complete -c ffmpeg -o pre -o preset -d "Preset name"
|
||||
__fish_ffmpeg_complete_regex 'pre(set)?' "(__fish_ffmpeg_presets)"
|
||||
complete -c ffmpeg -o tune
|
||||
__fish_ffmpeg_complete_regex 'tune' "(__fish_ffmpeg_tunes)"
|
||||
__fish_ffmpeg_complete_regex tune "(__fish_ffmpeg_tunes)"
|
||||
complete -c ffmpeg -o crf -o q
|
||||
__fish_ffmpeg_complete_regex 'crf|q' "(__fish_ffmpeg_crfs)"
|
||||
complete -c ffmpeg -o profile
|
||||
__fish_ffmpeg_complete_regex 'profile' "(__fish_ffmpeg_profiles)"
|
||||
__fish_ffmpeg_complete_regex profile "(__fish_ffmpeg_profiles)"
|
||||
|
||||
# Filters
|
||||
#
|
||||
|
@ -281,11 +281,11 @@ function __fish_ffmpeg_concat_filter_args
|
|||
end
|
||||
|
||||
function __fish_ffmpeg_complete_filter
|
||||
set -l filter_type "all"
|
||||
set -l filter_type all
|
||||
if string match -rq -- '^-(vf(ilter)?|f(ilter)?:v)' (__fish_ffmpeg_last_arg)
|
||||
set filter_type "video"
|
||||
set filter_type video
|
||||
else if string match -rq -- '^-(af(ilter)?|f(ilter)?:a' (__fish_ffmpeg_last_arg)
|
||||
set filter_type "audio"
|
||||
set filter_type audio
|
||||
end
|
||||
|
||||
# echo -e "\n **** $filter_type **** \n" > /dev/tty
|
||||
|
|
|
@ -9,4 +9,4 @@ complete -f -c gapplication -n __fish_use_subcommand -a list-actions -d "List av
|
|||
complete -f -c gapplication -n __fish_use_subcommand -a action -d "Activate an action"
|
||||
|
||||
# Arguments of help command
|
||||
complete -f -c gapplication -n "__fish_seen_subcommand_from help" -a "help version list-apps launch list-actions action" -d "Command"
|
||||
complete -f -c gapplication -n "__fish_seen_subcommand_from help" -a "help version list-apps launch list-actions action" -d Command
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
set -l supported_schemes admin afc afp archive burn cdda computer dav dav+sd davs davs+sd dns-sd file ftp ftpis ftps google-drive gphoto2 http https localtest mtp network nfs recent sftp smb ssh test trash
|
||||
|
||||
for scheme in $supported_schemes
|
||||
complete -c gio -n "__fish_seen_subcommand_from cat copy info list mkdir monitor mount move open rename remove save set trash tree" -a "$scheme": -d "Scheme"
|
||||
complete -c gio -n "__fish_seen_subcommand_from cat copy info list mkdir monitor mount move open rename remove save set trash tree" -a "$scheme": -d Scheme
|
||||
end
|
||||
|
||||
# Commands
|
||||
|
@ -28,7 +28,7 @@ complete -f -c gio -n __fish_use_subcommand -a trash -d "Move files to the trash
|
|||
complete -f -c gio -n __fish_use_subcommand -a tree -d "Lists the contents of locations in a tree"
|
||||
|
||||
# Arguments of help command
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from help" -a "version cat copy info list mime mkdir monitor mount move open rename remove save set trash tree" -d "Command"
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from help" -a "version cat copy info list mime mkdir monitor mount move open rename remove save set trash tree" -d Command
|
||||
|
||||
# Arguments of mime command
|
||||
function __fish_gio_list_mimetypes
|
||||
|
@ -76,13 +76,13 @@ complete -f -c gio -n "__fish_seen_subcommand_from monitor" -s m -l mounts -d "W
|
|||
# Options of mount command
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s m -l mountable -d "Mount as mountable"
|
||||
complete -x -c gio -n "__fish_seen_subcommand_from mount" -s d -l device -d "Mount volume"
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s u -l unmount -d "Unmount"
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s e -l eject -d "Eject"
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s u -l unmount -d Unmount
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s e -l eject -d Eject
|
||||
complete -x -c gio -n "__fish_seen_subcommand_from mount" -s t -l stop -d "Stop drive"
|
||||
complete -x -c gio -n "__fish_seen_subcommand_from mount" -s s -l unmount-scheme -a "$supported_schemes" -d "Unmount all mounts with the given scheme"
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s f -l force -d "Ignore outstanding file operations"
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s a -l anonymous -d "Use an anonymous user"
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s l -l list -d "List"
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s l -l list -d List
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s o -l monitor -d "Monitor events"
|
||||
complete -f -c gio -n "__fish_seen_subcommand_from mount" -s i -l detail -d "Show extra information"
|
||||
complete -x -c gio -n "__fish_seen_subcommand_from mount" -l tcrypt-pim -d "The numeric PIM when unlocking a VeraCrypt volume"
|
||||
|
|
|
@ -11,4 +11,4 @@ complete -f -c gresource -n "__fish_not_contain_opt section && __fish_use_subcom
|
|||
complete -f -c gresource -n "__fish_not_contain_opt section && __fish_use_subcommand" -a help -d "Prints help"
|
||||
|
||||
# Arguments of help command
|
||||
complete -f -c gresource -n "__fish_seen_subcommand_from help" -a "list details extract sections help" -d "Command"
|
||||
complete -f -c gresource -n "__fish_seen_subcommand_from help" -a "list details extract sections help" -d Command
|
||||
|
|
|
@ -18,7 +18,7 @@ complete -c vips -l vips-config -d 'Print libvips config'
|
|||
complete -c vips -l vips-pipe-read-limit -d 'Pipe read limit (bytes)'
|
||||
|
||||
# Operations
|
||||
complete -c vips -n '__fish_is_first_token' -xa "(__fish_vips_ops)"
|
||||
complete -c vips -n __fish_is_first_token -xa "(__fish_vips_ops)"
|
||||
|
||||
function __fish_vips_ops
|
||||
vips -l | string match -rv _base | string replace -rf '^\s*\S+ \((.+?)\), +(\S.*?)(?:\s*[,(].*)?$' '$1\t$2'
|
||||
|
|
|
@ -135,7 +135,6 @@ function __fish_complete_mount_opts
|
|||
barrier={0,1}\
|
||||
user_xattr\
|
||||
acl\
|
||||
|
||||
set -l token (commandline -tc | string replace -r '^-o' -- '')
|
||||
set -l args (string split , -- $token)
|
||||
|
||||
|
|
|
@ -392,7 +392,9 @@ class Type2ManParser(ManParser):
|
|||
options_section_regex = re.compile("\.SH OPTIONS(.*?)(\.SH|\Z)", re.DOTALL)
|
||||
options_section = re.search(options_section_regex, manpage).group(1)
|
||||
|
||||
options_parts_regex = re.compile("\.[IT]P( \d+(\.\d)?i?)?(.*?)\.([IT]P|UNINDENT|UN|SH)", re.DOTALL)
|
||||
options_parts_regex = re.compile(
|
||||
"\.[IT]P( \d+(\.\d)?i?)?(.*?)\.([IT]P|UNINDENT|UN|SH)", re.DOTALL
|
||||
)
|
||||
options_matched = re.search(options_parts_regex, options_section)
|
||||
add_diagnostic("Command is %r" % CMDNAME)
|
||||
|
||||
|
@ -421,6 +423,7 @@ class Type2ManParser(ManParser):
|
|||
options_section = options_section[options_matched.end() - 3 :]
|
||||
options_matched = re.search(options_parts_regex, options_section)
|
||||
|
||||
|
||||
class Type3ManParser(ManParser):
|
||||
def is_my_type(self, manpage):
|
||||
return compile_and_search("\.SH DESCRIPTION(.*?)", manpage) != None
|
||||
|
@ -467,7 +470,9 @@ class Type4ManParser(ManParser):
|
|||
return compile_and_search("\.SH FUNCTION LETTERS(.*?)", manpage) != None
|
||||
|
||||
def parse_man_page(self, manpage):
|
||||
options_section_regex = re.compile("\.SH FUNCTION LETTERS(.*?)(\.SH|\Z)", re.DOTALL)
|
||||
options_section_regex = re.compile(
|
||||
"\.SH FUNCTION LETTERS(.*?)(\.SH|\Z)", re.DOTALL
|
||||
)
|
||||
options_section = re.search(options_section_regex, manpage).group(1)
|
||||
|
||||
options_parts_regex = re.compile("\.TP(.*?)\.TP", re.DOTALL)
|
||||
|
@ -502,9 +507,15 @@ class Type4ManParser(ManParser):
|
|||
options_section = options_section[options_matched.end() - 3 :]
|
||||
options_matched = re.search(options_parts_regex, options_section)
|
||||
|
||||
|
||||
class TypeScdocManParser(ManParser):
|
||||
def is_my_type(self, manpage):
|
||||
return compile_and_search(r"\.(\\)(\") Generated by scdoc(.*?)\.SH OPTIONS(.*?)", manpage) != None
|
||||
return (
|
||||
compile_and_search(
|
||||
r"\.(\\)(\") Generated by scdoc(.*?)\.SH OPTIONS(.*?)", manpage
|
||||
)
|
||||
!= None
|
||||
)
|
||||
|
||||
def parse_man_page(self, manpage):
|
||||
options_section_regex = re.compile("\.SH OPTIONS(.*?)\.SH", re.DOTALL)
|
||||
|
@ -758,6 +769,7 @@ def cleanup_autogenerated_file(path):
|
|||
except (OSError, IOError):
|
||||
pass
|
||||
|
||||
|
||||
def parse_manpage_at_path(manpage_path, output_directory):
|
||||
# Return if CMDNAME is in 'ignoredcommands'
|
||||
ignoredcommands = [
|
||||
|
@ -868,8 +880,9 @@ def parse_manpage_at_path(manpage_path, output_directory):
|
|||
return False
|
||||
|
||||
# Output the magic word Autogenerated so we can tell if we can overwrite this
|
||||
built_command_output.insert(0, "# " + CMDNAME +
|
||||
"\n# Autogenerated from man page " + manpage_path)
|
||||
built_command_output.insert(
|
||||
0, "# " + CMDNAME + "\n# Autogenerated from man page " + manpage_path
|
||||
)
|
||||
# built_command_output.insert(2, "# using " + parser.__class__.__name__) # XXX MISATTRIBUTES THE CULPABLE PARSER! Was really using Type2 but reporting TypeDeroffManParser
|
||||
|
||||
for line in built_command_output:
|
||||
|
@ -1021,7 +1034,10 @@ if __name__ == "__main__":
|
|||
action="append",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-d", "--directory", type=str, help="The directory to save the completions in",
|
||||
"-d",
|
||||
"--directory",
|
||||
type=str,
|
||||
help="The directory to save the completions in",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-k",
|
||||
|
@ -1030,13 +1046,22 @@ if __name__ == "__main__":
|
|||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-m", "--manpath", help="Whether to use manpath", action="store_true",
|
||||
"-m",
|
||||
"--manpath",
|
||||
help="Whether to use manpath",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p", "--progress", help="Whether to show progress", action="store_true",
|
||||
"-p",
|
||||
"--progress",
|
||||
help="Whether to show progress",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s", "--stdout", help="Write the completions to stdout", action="store_true",
|
||||
"-s",
|
||||
"--stdout",
|
||||
help="Write the completions to stdout",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
|
@ -1046,7 +1071,10 @@ if __name__ == "__main__":
|
|||
help="The level of debug output to show",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-z", "--deroff-only", help="Whether to just deroff", action="store_true",
|
||||
"-z",
|
||||
"--deroff-only",
|
||||
help="Whether to just deroff",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument("file_paths", type=str, nargs="*")
|
||||
|
||||
|
|
|
@ -165,8 +165,7 @@ def better_color(c1, c2):
|
|||
|
||||
|
||||
def parse_color(color_str):
|
||||
""" A basic function to parse a color string, for example, 'red' '--bold'.
|
||||
"""
|
||||
"""A basic function to parse a color string, for example, 'red' '--bold'."""
|
||||
comps = color_str.split(" ")
|
||||
color = "normal"
|
||||
background_color = ""
|
||||
|
@ -1174,7 +1173,9 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
|||
except ImportError:
|
||||
# If the platform doesn't support multiprocessing, we just do it one at a time.
|
||||
# This happens e.g. on Termux.
|
||||
print("Platform doesn't support multiprocessing, running one at a time. This may take a while.")
|
||||
print(
|
||||
"Platform doesn't support multiprocessing, running one at a time. This may take a while."
|
||||
)
|
||||
result.append(self.do_get_current_prompt())
|
||||
result.extend([self.read_one_sample_prompt(path) for path in paths])
|
||||
return result
|
||||
|
@ -1499,6 +1500,7 @@ print(
|
|||
)
|
||||
print("%sHit ENTER to stop.%s" % (esc["bold"], esc["exit_attribute_mode"]))
|
||||
|
||||
|
||||
def runThing():
|
||||
if isMacOS10_12_5_OrLater():
|
||||
subprocess.check_call(["open", fileurl])
|
||||
|
@ -1509,6 +1511,7 @@ def runThing():
|
|||
else:
|
||||
webbrowser.open(fileurl)
|
||||
|
||||
|
||||
# Some browsers still block webbrowser.open if they haven't been opened before,
|
||||
# so we just spawn it in a thread.
|
||||
thread = threading.Thread(target=runThing)
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
//
|
||||
// 1). Create a function in builtin.c with the following signature:
|
||||
//
|
||||
// <tt>static maybe_t<int> builtin_NAME(parser_t &parser, io_streams_t &streams, wchar_t **argv)</tt>
|
||||
// <tt>static maybe_t<int> builtin_NAME(parser_t &parser, io_streams_t &streams, wchar_t
|
||||
// **argv)</tt>
|
||||
//
|
||||
// where NAME is the name of the builtin, and args is a zero-terminated list of arguments.
|
||||
//
|
||||
|
@ -257,7 +258,8 @@ static maybe_t<int> builtin_count(parser_t &parser, io_streams_t &streams, wchar
|
|||
|
||||
/// This function handles both the 'continue' and the 'break' builtins that are used for loop
|
||||
/// control.
|
||||
static maybe_t<int> builtin_break_continue(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
||||
static maybe_t<int> builtin_break_continue(parser_t &parser, io_streams_t &streams,
|
||||
wchar_t **argv) {
|
||||
int is_break = (std::wcscmp(argv[0], L"break") == 0);
|
||||
int argc = builtin_count_args(argv);
|
||||
|
||||
|
|
|
@ -23,12 +23,10 @@ struct command_cmd_opts_t {
|
|||
bool all_paths = false;
|
||||
};
|
||||
static const wchar_t *const short_options = L":ahqsv";
|
||||
static const struct woption long_options[] = {{L"help", no_argument, nullptr, 'h'},
|
||||
{L"all", no_argument, nullptr, 'a'},
|
||||
{L"quiet", no_argument, nullptr, 'q'},
|
||||
{L"query", no_argument, nullptr, 'q'},
|
||||
{L"search", no_argument, nullptr, 's'},
|
||||
{nullptr, 0, nullptr, 0}};
|
||||
static const struct woption long_options[] = {
|
||||
{L"help", no_argument, nullptr, 'h'}, {L"all", no_argument, nullptr, 'a'},
|
||||
{L"quiet", no_argument, nullptr, 'q'}, {L"query", no_argument, nullptr, 'q'},
|
||||
{L"search", no_argument, nullptr, 's'}, {nullptr, 0, nullptr, 0}};
|
||||
|
||||
static int parse_cmd_opts(command_cmd_opts_t &opts, int *optind, int argc, wchar_t **argv,
|
||||
parser_t &parser, io_streams_t &streams) {
|
||||
|
|
|
@ -79,7 +79,8 @@ maybe_t<int> builtin_fg(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
|||
streams.err.append_format(_(L"%ls: No suitable job: %d\n"), cmd, pid);
|
||||
job = nullptr;
|
||||
} else if (!job->wants_job_control()) {
|
||||
streams.err.append_format(_(L"%ls: Can't put job %d, '%ls' to foreground because it is not under job control\n"),
|
||||
streams.err.append_format(_(L"%ls: Can't put job %d, '%ls' to foreground because "
|
||||
L"it is not under job control\n"),
|
||||
cmd, pid, job->command_wcstr());
|
||||
job = nullptr;
|
||||
}
|
||||
|
|
|
@ -199,8 +199,9 @@ static int validate_function_name(int argc, const wchar_t *const *argv, wcstring
|
|||
|
||||
/// Define a function. Calls into `function.cpp` to perform the heavy lifting of defining a
|
||||
/// function.
|
||||
maybe_t<int> builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_list_t &c_args,
|
||||
const parsed_source_ref_t &source, const ast::block_statement_t &func_node) {
|
||||
maybe_t<int> builtin_function(parser_t &parser, io_streams_t &streams,
|
||||
const wcstring_list_t &c_args, const parsed_source_ref_t &source,
|
||||
const ast::block_statement_t &func_node) {
|
||||
assert(source && "Missing source in builtin_function");
|
||||
// The wgetopt function expects 'function' as the first argument. Make a new wcstring_list with
|
||||
// that property. This is needed because this builtin has a different signature than the other
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace ast {
|
|||
struct block_statement_t;
|
||||
}
|
||||
|
||||
maybe_t<int> builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_list_t &c_args,
|
||||
const parsed_source_ref_t &source, const ast::block_statement_t &func_node);
|
||||
maybe_t<int> builtin_function(parser_t &parser, io_streams_t &streams,
|
||||
const wcstring_list_t &c_args, const parsed_source_ref_t &source,
|
||||
const ast::block_statement_t &func_node);
|
||||
#endif
|
||||
|
|
|
@ -286,7 +286,8 @@ maybe_t<int> builtin_functions(parser_t &parser, io_streams_t &streams, wchar_t
|
|||
wcstring new_func;
|
||||
|
||||
if (argc - optind != 2) {
|
||||
streams.err.append_format(_(L"%ls: Expected exactly two names (current function name, and new function name)\n"),
|
||||
streams.err.append_format(_(L"%ls: Expected exactly two names (current function name, "
|
||||
L"and new function name)\n"),
|
||||
cmd);
|
||||
builtin_print_error_trailer(parser, streams.err, cmd);
|
||||
return STATUS_INVALID_ARGS;
|
||||
|
|
|
@ -129,14 +129,11 @@ maybe_t<int> builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **arg
|
|||
bool print_last = false;
|
||||
|
||||
static const wchar_t *const short_options = L":cghlpq";
|
||||
static const struct woption long_options[] = {{L"command", no_argument, nullptr, 'c'},
|
||||
{L"group", no_argument, nullptr, 'g'},
|
||||
{L"help", no_argument, nullptr, 'h'},
|
||||
{L"last", no_argument, nullptr, 'l'},
|
||||
{L"pid", no_argument, nullptr, 'p'},
|
||||
{L"quiet", no_argument, nullptr, 'q'},
|
||||
{L"query", no_argument, nullptr, 'q'},
|
||||
{nullptr, 0, nullptr, 0}};
|
||||
static const struct woption long_options[] = {
|
||||
{L"command", no_argument, nullptr, 'c'}, {L"group", no_argument, nullptr, 'g'},
|
||||
{L"help", no_argument, nullptr, 'h'}, {L"last", no_argument, nullptr, 'l'},
|
||||
{L"pid", no_argument, nullptr, 'p'}, {L"quiet", no_argument, nullptr, 'q'},
|
||||
{L"query", no_argument, nullptr, 'q'}, {nullptr, 0, nullptr, 0}};
|
||||
|
||||
int opt;
|
||||
wgetopter_t w;
|
||||
|
|
|
@ -489,8 +489,9 @@ maybe_t<int> builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **arg
|
|||
int stream_stdin_is_a_tty = isatty(streams.stdin_fd);
|
||||
if (stream_stdin_is_a_tty && !opts.split_null) {
|
||||
// Read interactively using reader_readline(). This does not support splitting on null.
|
||||
exit_res = read_interactive(parser, buff, opts.nchars, opts.shell, opts.silent,
|
||||
opts.prompt, opts.right_prompt, opts.commandline, streams.stdin_fd);
|
||||
exit_res =
|
||||
read_interactive(parser, buff, opts.nchars, opts.shell, opts.silent, opts.prompt,
|
||||
opts.right_prompt, opts.commandline, streams.stdin_fd);
|
||||
} else if (!opts.nchars && !stream_stdin_is_a_tty &&
|
||||
lseek(streams.stdin_fd, 0, SEEK_CUR) != -1) {
|
||||
exit_res = read_in_chunks(streams.stdin_fd, buff, opts.split_null);
|
||||
|
|
|
@ -91,7 +91,8 @@ maybe_t<int> builtin_realpath(parser_t &parser, io_streams_t &streams, wchar_t *
|
|||
std::strerror(errno));
|
||||
} else {
|
||||
// Who knows. Probably a bug in our wrealpath() implementation.
|
||||
streams.err.append_format(_(L"builtin %ls: Invalid path: %ls\n"), cmd, argv[optind]);
|
||||
streams.err.append_format(_(L"builtin %ls: Invalid path: %ls\n"), cmd,
|
||||
argv[optind]);
|
||||
}
|
||||
|
||||
return STATUS_CMD_ERROR;
|
||||
|
|
|
@ -643,7 +643,8 @@ static int builtin_set_erase(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
|
|||
parser_t &parser, io_streams_t &streams) {
|
||||
int ret = STATUS_CMD_OK;
|
||||
for (int i = 0; i < argc; i++) {
|
||||
int scope = compute_scope(opts); // calculate the variable scope based on the provided options
|
||||
int scope =
|
||||
compute_scope(opts); // calculate the variable scope based on the provided options
|
||||
wchar_t *dest = argv[i];
|
||||
|
||||
std::vector<long> indexes;
|
||||
|
@ -675,7 +676,8 @@ static int builtin_set_erase(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
|
|||
wcstring_list_t result;
|
||||
dest_var->to_list(result);
|
||||
erase_values(result, indexes);
|
||||
retval = env_set_reporting_errors(cmd, dest, scope, result, streams, parser.vars(), &evts);
|
||||
retval =
|
||||
env_set_reporting_errors(cmd, dest, scope, result, streams, parser.vars(), &evts);
|
||||
}
|
||||
|
||||
// Fire any events.
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
|
||||
class parser_t;
|
||||
|
||||
static void print_modifiers(outputter_t &outp, bool bold, bool underline, bool italics, bool dim, bool reverse, rgb_color_t bg) {
|
||||
static void print_modifiers(outputter_t &outp, bool bold, bool underline, bool italics, bool dim,
|
||||
bool reverse, rgb_color_t bg) {
|
||||
if (bold && enter_bold_mode) {
|
||||
// These casts are needed to work with different curses implementations.
|
||||
writembs_nofail(outp, tparm(const_cast<char *>(enter_bold_mode)));
|
||||
|
@ -59,11 +60,10 @@ static void print_modifiers(outputter_t &outp, bool bold, bool underline, bool i
|
|||
if (!bg.is_none() && bg.is_normal()) {
|
||||
writembs_nofail(outp, tparm(const_cast<char *>(exit_attribute_mode)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void print_colors(io_streams_t &streams, bool bold, bool underline, bool italics, bool dim, bool reverse, rgb_color_t bg) {
|
||||
static void print_colors(io_streams_t &streams, bool bold, bool underline, bool italics, bool dim,
|
||||
bool reverse, rgb_color_t bg) {
|
||||
outputter_t outp;
|
||||
for (const auto &color_name : rgb_color_t::named_color_names()) {
|
||||
if (!streams.out_is_redirected && isatty(STDOUT_FILENO)) {
|
||||
|
@ -134,7 +134,8 @@ maybe_t<int> builtin_set_color(parser_t &parser, io_streams_t &streams, wchar_t
|
|||
}
|
||||
|
||||
const wchar_t *bgcolor = nullptr;
|
||||
bool bold = false, underline = false, italics = false, dim = false, reverse = false, print = false;
|
||||
bool bold = false, underline = false, italics = false, dim = false, reverse = false,
|
||||
print = false;
|
||||
|
||||
// Parse options to obtain the requested operation and the modifiers.
|
||||
int opt;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "builtin_type.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "builtin.h"
|
||||
|
|
|
@ -206,9 +206,10 @@ bool is_windows_subsystem_for_linux() {
|
|||
int status = -1;
|
||||
if (info.dli_sname[0] == '_')
|
||||
demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status);
|
||||
swprintf(
|
||||
text, sizeof(text) / sizeof(wchar_t), L"%-3d %s + %td", i - skip_levels,
|
||||
status == 0 ? demangled : info.dli_sname == nullptr ? symbols[i] : info.dli_sname,
|
||||
swprintf(text, sizeof(text) / sizeof(wchar_t), L"%-3d %s + %td", i - skip_levels,
|
||||
status == 0 ? demangled
|
||||
: info.dli_sname == nullptr ? symbols[i]
|
||||
: info.dli_sname,
|
||||
static_cast<char *>(callstack[i]) - static_cast<char *>(info.dli_saddr));
|
||||
free(demangled);
|
||||
} else {
|
||||
|
|
|
@ -1116,8 +1116,8 @@ static bool should_import_bash_history_line(const wcstring &line) {
|
|||
if (line.find(L"]]") != std::string::npos) return false;
|
||||
if (line.find(L"((") != std::string::npos) return false;
|
||||
if (line.find(L"))") != std::string::npos) return false;
|
||||
// Skip lines with literal tabs since we don't handle them well and we don't know what they mean.
|
||||
// It could just be whitespace or it's actually passed somewhere (like e.g. `sed`).
|
||||
// Skip lines with literal tabs since we don't handle them well and we don't know what they
|
||||
// mean. It could just be whitespace or it's actually passed somewhere (like e.g. `sed`).
|
||||
if (line.find(L'\t') != std::string::npos) return false;
|
||||
|
||||
// Skip lines that end with a backslash. We do not handle multiline commands from bash history.
|
||||
|
|
|
@ -194,6 +194,7 @@ class input_event_queue_t {
|
|||
char_event_t readb();
|
||||
|
||||
int in_{0};
|
||||
|
||||
public:
|
||||
input_event_queue_t(int in = 0) : in_(in){};
|
||||
|
||||
|
|
|
@ -208,7 +208,8 @@ enum class pipeline_position_t {
|
|||
|
||||
/// Error message on reaching maximum call stack depth.
|
||||
#define CALL_STACK_LIMIT_EXCEEDED_ERR_MSG \
|
||||
_(L"The function call stack limit has been exceeded. Do you have an accidental infinite loop?")
|
||||
_(L"The function call stack limit has been exceeded. Do you have an accidental infinite " \
|
||||
L"loop?")
|
||||
|
||||
/// Error message when encountering an illegal command name.
|
||||
#define ILLEGAL_CMD_ERR_MSG _(L"Illegal command name '%ls'")
|
||||
|
|
|
@ -754,7 +754,8 @@ end_execution_reason_t parse_execution_context_t::handle_command_not_found(
|
|||
|
||||
// Redirect to stderr
|
||||
auto io = io_chain_t{};
|
||||
io.append_from_specs({redirection_spec_t{STDOUT_FILENO, redirection_mode_t::fd, L"2"}}, L"");
|
||||
io.append_from_specs({redirection_spec_t{STDOUT_FILENO, redirection_mode_t::fd, L"2"}},
|
||||
L"");
|
||||
|
||||
if (function_exists(L"fish_command_not_found", *parser)) {
|
||||
buffer = L"fish_command_not_found";
|
||||
|
|
|
@ -380,7 +380,8 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
|||
auto len = strlen(interpreter);
|
||||
if (len && interpreter[len - 1] == '\r') {
|
||||
debug_safe(0,
|
||||
"The file uses windows line endings (\\r\\n). Run dos2unix or similar to fix it.");
|
||||
"The file uses windows line endings (\\r\\n). Run dos2unix or "
|
||||
"similar to fix it.");
|
||||
} else {
|
||||
debug_safe(0,
|
||||
"The file '%s' specified the interpreter '%s', which is not an "
|
||||
|
|
|
@ -144,10 +144,10 @@ static operation_context_t get_bg_context(const std::shared_ptr<environment_t> &
|
|||
return operation_context_t{nullptr, *env, std::move(cancel_checker)};
|
||||
}
|
||||
|
||||
/// We try to ensure that syntax highlighting completes appropriately before executing what the user typed.
|
||||
/// But we do not want it to block forever - e.g. it may hang on determining if an arbitrary argument
|
||||
/// is a path. This is how long we'll wait (in milliseconds) before giving up and performing a
|
||||
/// no-io syntax highlighting. See #7418, #5912.
|
||||
/// We try to ensure that syntax highlighting completes appropriately before executing what the user
|
||||
/// typed. But we do not want it to block forever - e.g. it may hang on determining if an arbitrary
|
||||
/// argument is a path. This is how long we'll wait (in milliseconds) before giving up and
|
||||
/// performing a no-io syntax highlighting. See #7418, #5912.
|
||||
static constexpr long kHighlightTimeoutForExecutionMs = 250;
|
||||
|
||||
/// Get the debouncer for autosuggestions and background highlighting.
|
||||
|
@ -411,8 +411,7 @@ class reader_history_search_t {
|
|||
// We can skip dedup in history_search_t because we do it ourselves in skips_.
|
||||
search_ = history_search_t(
|
||||
*hist, text,
|
||||
by_prefix() ? history_search_type_t::prefix : history_search_type_t::contains,
|
||||
flags);
|
||||
by_prefix() ? history_search_type_t::prefix : history_search_type_t::contains, flags);
|
||||
}
|
||||
|
||||
/// Reset to inactive search.
|
||||
|
@ -2071,7 +2070,8 @@ static void acquire_tty_or_exit(pid_t shell_pgid) {
|
|||
if (check_for_orphaned_process(loop_count, shell_pgid)) {
|
||||
// We're orphaned, so we just die. Another sad statistic.
|
||||
const wchar_t *fmt =
|
||||
_(L"I appear to be an orphaned process, so I am quitting politely. My pid is %d.");
|
||||
_(L"I appear to be an orphaned process, so I am quitting politely. My pid is "
|
||||
L"%d.");
|
||||
FLOGF(warning, fmt, static_cast<int>(getpid()));
|
||||
exit_without_destructors(1);
|
||||
}
|
||||
|
@ -2823,8 +2823,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
|
|||
//
|
||||
// Also paging is already cancelled above.
|
||||
if (rls.complete_did_insert &&
|
||||
(rls.last_cmd == rl::complete
|
||||
|| rls.last_cmd == rl::complete_and_search)) {
|
||||
(rls.last_cmd == rl::complete || rls.last_cmd == rl::complete_and_search)) {
|
||||
editable_line_t *el = active_edit_line();
|
||||
el->undo();
|
||||
update_buff_pos(el);
|
||||
|
@ -3241,8 +3240,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
|
|||
case rl::backward_kill_path_component:
|
||||
case rl::backward_kill_bigword: {
|
||||
move_word_style_t style =
|
||||
(c == rl::backward_kill_bigword
|
||||
? move_word_style_whitespace
|
||||
(c == rl::backward_kill_bigword ? move_word_style_whitespace
|
||||
: c == rl::backward_kill_path_component ? move_word_style_path_components
|
||||
: move_word_style_punctuation);
|
||||
// Is this the same killring item as the last kill?
|
||||
|
@ -3783,7 +3781,8 @@ maybe_t<wcstring> reader_data_t::readline(int nchars_or_0) {
|
|||
|
||||
// Redraw the command line. This is what ensures the autosuggestion is hidden, etc. after the
|
||||
// user presses enter.
|
||||
if (this->is_repaint_needed() || conf.in != STDIN_FILENO) this->layout_and_repaint(L"prepare to execute");
|
||||
if (this->is_repaint_needed() || conf.in != STDIN_FILENO)
|
||||
this->layout_and_repaint(L"prepare to execute");
|
||||
|
||||
// Finish any outstanding syntax highlighting (but do not wait forever).
|
||||
finish_highlighting_before_exec();
|
||||
|
|
|
@ -430,7 +430,8 @@ wcstring normalize_path(const wcstring &path, bool allow_leading_double_slashes)
|
|||
wcstring result = join_strings(new_comps, sep);
|
||||
// Prepend one or two leading slashes.
|
||||
// Two slashes are preserved. Three+ slashes are collapsed to one. (!)
|
||||
result.insert(0, allow_leading_double_slashes && leading_slashes > 2 ? 1 : leading_slashes, sep);
|
||||
result.insert(0, allow_leading_double_slashes && leading_slashes > 2 ? 1 : leading_slashes,
|
||||
sep);
|
||||
// Ensure ./ normalizes to . and not empty.
|
||||
if (result.empty()) result.push_back(L'.');
|
||||
return result;
|
||||
|
|
|
@ -309,5 +309,5 @@ expect_prompt("\nb c d")
|
|||
# Check that ctrl-z can be bound
|
||||
sendline('bind \cz "echo bound ctrl-z"')
|
||||
expect_prompt()
|
||||
send('\x1A')
|
||||
send("\x1A")
|
||||
expect_str("bound ctrl-z")
|
||||
|
|
|
@ -4,7 +4,13 @@ from pexpect_helper import SpawnedProc
|
|||
import signal
|
||||
|
||||
sp = SpawnedProc()
|
||||
send, sendline, sleep, expect_str, expect_prompt = sp.send, sp.sendline, sp.sleep, sp.expect_str, sp.expect_prompt
|
||||
send, sendline, sleep, expect_str, expect_prompt = (
|
||||
sp.send,
|
||||
sp.sendline,
|
||||
sp.sleep,
|
||||
sp.expect_str,
|
||||
sp.expect_prompt,
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# Verify that cancel-commandline does what we expect - see #7384.
|
||||
|
|
|
@ -52,7 +52,9 @@ send("exit\r")
|
|||
|
||||
for t in range(0, 3):
|
||||
proc = subprocess.run(
|
||||
["pgrep", "-l", "-f", "sleep 11"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
["pgrep", "-l", "-f", "sleep 11"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
break
|
||||
|
|
|
@ -18,11 +18,13 @@ expect_prompt()
|
|||
sendline("test -t 0; echo $status")
|
||||
expect_prompt("0")
|
||||
|
||||
sendline("""function t
|
||||
sendline(
|
||||
"""function t
|
||||
test -t 0 && echo stdin
|
||||
test -t 1 && echo stdout
|
||||
test -t 2 && echo stderr
|
||||
end""")
|
||||
end"""
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
sendline("t")
|
||||
|
|
|
@ -40,7 +40,7 @@ expect_re("Job.*Group.*(CPU)?.*State.*Command")
|
|||
expect_re(".*running.*sleep 20 &")
|
||||
expect_prompt()
|
||||
sendline("echo $my_pid")
|
||||
m = expect_re('\d+\r\n')
|
||||
m = expect_re("\d+\r\n")
|
||||
expect_prompt()
|
||||
os.kill(int(m.group()), signal.SIGTERM)
|
||||
expect_re("[0-9]+:0:sleep 20 &:SIGTERM:Polite quit request", timeout=20)
|
||||
|
|
|
@ -7,7 +7,9 @@ sendline, expect_prompt, expect_str = sp.sendline, sp.expect_prompt, sp.expect_s
|
|||
# Test fish_postexec and $status_generation for interactive shells.
|
||||
expect_prompt()
|
||||
|
||||
sendline("function test_fish_postexec --on-event fish_postexec; printf 'pipestatus:%s, generation:%d, command:%s\\n' (string join '|' $pipestatus) $status_generation $argv; end")
|
||||
sendline(
|
||||
"function test_fish_postexec --on-event fish_postexec; printf 'pipestatus:%s, generation:%d, command:%s\\n' (string join '|' $pipestatus) $status_generation $argv; end"
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
generation = 1
|
||||
|
@ -38,7 +40,9 @@ expect_prompt()
|
|||
|
||||
# multiple backgrounded jobs
|
||||
sendline("sleep 1000 &; sleep 2000 &")
|
||||
expect_str("pipestatus:0|1, generation:%d, command:sleep 1000 &; sleep 2000 &" % generation)
|
||||
expect_str(
|
||||
"pipestatus:0|1, generation:%d, command:sleep 1000 &; sleep 2000 &" % generation
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# valid variable assignment
|
||||
|
@ -48,18 +52,25 @@ expect_prompt()
|
|||
|
||||
# valid variable assignment with background job
|
||||
sendline("set foo bar; sleep 1000 &")
|
||||
expect_str("pipestatus:0|1, generation:%d, command:set foo bar; sleep 1000 &" % generation)
|
||||
expect_str(
|
||||
"pipestatus:0|1, generation:%d, command:set foo bar; sleep 1000 &" % generation
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# Increments $status_generation if any job was foreground.
|
||||
sendline("false|true; sleep 1000 &")
|
||||
generation += 1
|
||||
expect_str("pipestatus:1|0, generation:%d, command:false|true; sleep 1000 &" % generation)
|
||||
expect_str(
|
||||
"pipestatus:1|0, generation:%d, command:false|true; sleep 1000 &" % generation
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
sendline("sleep 1000 &; true|false|true")
|
||||
generation += 1
|
||||
expect_str("pipestatus:0|1|0, generation:%d, command:sleep 1000 &; true|false|true" % generation)
|
||||
expect_str(
|
||||
"pipestatus:0|1|0, generation:%d, command:sleep 1000 &; true|false|true"
|
||||
% generation
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# Increments $status_generation for empty if/while blocks.
|
||||
|
@ -83,7 +94,9 @@ expect_prompt()
|
|||
# This is an implementation detail, but the test case should prevent regressions.
|
||||
sendline("function fail; false; end")
|
||||
generation += 1
|
||||
expect_str("pipestatus:0, generation:%d, command:function fail; false; end" % generation)
|
||||
expect_str(
|
||||
"pipestatus:0, generation:%d, command:function fail; false; end" % generation
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# or an invalid variable assignment
|
||||
|
@ -111,15 +124,24 @@ expect_prompt()
|
|||
|
||||
# Or begin/end block with only backgrounded jobs.
|
||||
sendline("begin; sleep 200 &; sleep 400 &; end")
|
||||
expect_str("pipestatus:0|1|0, generation:%d, command:begin; sleep 200 &; sleep 400 &; end" % generation)
|
||||
expect_str(
|
||||
"pipestatus:0|1|0, generation:%d, command:begin; sleep 200 &; sleep 400 &; end"
|
||||
% generation
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# Or a combination of begin/end block and backgrounded job.
|
||||
sendline("begin; sleep 200 &; end; sleep 400 &")
|
||||
expect_str("pipestatus:0|1|0, generation:%d, command:begin; sleep 200 &; end; sleep 400 &" % generation)
|
||||
expect_str(
|
||||
"pipestatus:0|1|0, generation:%d, command:begin; sleep 200 &; end; sleep 400 &"
|
||||
% generation
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# Or a combination with variable assignments
|
||||
sendline("begin; set foo bar; sleep 1000 &; end; set bar baz; sleep 2000 &")
|
||||
expect_str("pipestatus:0|1|0, generation:%d, command:begin; set foo bar; sleep 1000 &; end; set bar baz; sleep 2000 &" % generation)
|
||||
expect_str(
|
||||
"pipestatus:0|1|0, generation:%d, command:begin; set foo bar; sleep 1000 &; end; set bar baz; sleep 2000 &"
|
||||
% generation
|
||||
)
|
||||
expect_prompt()
|
||||
|
|
|
@ -60,4 +60,3 @@ expect_str("white")
|
|||
expect_str("yellow")
|
||||
expect_str("normal")
|
||||
expect_prompt()
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ expect_prompt()
|
|||
sendline("status job-control full")
|
||||
expect_prompt()
|
||||
|
||||
sendline("$fish -c 'status job-control full ; $fish_test_helper report_foreground' &; wait")
|
||||
sendline(
|
||||
"$fish -c 'status job-control full ; $fish_test_helper report_foreground' &; wait"
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
sendline("echo it worked")
|
||||
|
|
Loading…
Reference in New Issue
Block a user