aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc_src/string.txt7
-rw-r--r--share/functions/__fish_print_commands.fish8
-rw-r--r--share/functions/__fish_print_help.fish8
-rw-r--r--src/builtin_jobs.cpp2
-rw-r--r--src/fish_indent.cpp6
-rw-r--r--tests/jobs.err0
-rw-r--r--tests/jobs.in3
-rw-r--r--tests/jobs.out3
-rw-r--r--tests/jobs.status1
9 files changed, 30 insertions, 8 deletions
diff --git a/doc_src/string.txt b/doc_src/string.txt
index 2306678a..2996b456 100644
--- a/doc_src/string.txt
+++ b/doc_src/string.txt
@@ -44,10 +44,15 @@ The following subcommands are available:
- `escape` escapes each STRING such that it can be passed back to `eval` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If `-n` or `--no-quote` is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise.
-- `match` tests each STRING against PATTERN and prints matching substrings. Only the first match for each STRING is reported unless `-a` or `--all` is given, in which case all matches are reported. Matching can be made case-insensitive with `-i` or `--ignore-case`. If `-n` or `--index` is given, each match is reported as a 1-based start position and a length. By default, PATTERN is interpreted as a glob pattern matched against each entire STRING argument. If `-r` or `--regex` is given, PATTERN is interpreted as a Perl-compatible regular expression. For a regular expression containing capturing groups, multiple items will be reported for each match, one for the entire match and one for each capturing group. If --invert or -v is used the selected lines will be only those which do not match the given glob pattern or regular expression. Exit status: 0 if at least one match was found, or 1 otherwise.
+- `match` tests each STRING against PATTERN and prints matching substrings. Only the first match for each STRING is reported unless `-a` or `--all` is given, in which case all matches are reported. Matching can be made case-insensitive with `-i` or `--ignore-case`. If `-n` or `--index` is given, each match is reported as a 1-based start position and a length. By default, PATTERN is interpreted as a glob pattern matched against each entire STRING argument. A glob pattern is only considered a valid match if it matches the entire STRING. If `-r` or `--regex` is given, PATTERN is interpreted as a Perl-compatible regular expression, which does not have to match the entire STRING. For a regular expression containing capturing groups, multiple items will be reported for each match, one for the entire match and one for each capturing group. If --invert or -v is used the selected lines will be only those which do not match the given glob pattern or regular expression. Exit status: 0 if at least one match was found, or 1 otherwise.
- `replace` is similar to `match` but replaces non-overlapping matching substrings with a replacement string and prints the result. By default, PATTERN is treated as a literal substring to be matched. If `-r` or `--regex` is given, PATTERN is interpreted as a Perl-compatible regular expression, and REPLACEMENT can contain C-style escape sequences like `\t` as well as references to capturing groups by number or name as `$n` or `${n}`. Exit status: 0 if at least one replacement was performed, or 1 otherwise.
+\subsection regular-expressions Regular Expressions
+
+Both the `match` and `replace` subcommand support regular expressions when used with the `-r` or `--regex` option. The dialect is that of PCRE2.
+
+In general, special characters are special by default, so `a+` matches one or more "a"s, while `a\+` matches an "a" and then a "+". `(a+)` matches one or more "a"s in a capturing group (`(?:XXXX)` denotes a non-capturing group). For the replacement parameter of `replace`, `$n` refers to the n-th group of the match. In the match parameter, `\n` (e.g. `\1`) refers back to groups.
\subsection string-example Examples
diff --git a/share/functions/__fish_print_commands.fish b/share/functions/__fish_print_commands.fish
index 21c0876d..bac2bd73 100644
--- a/share/functions/__fish_print_commands.fish
+++ b/share/functions/__fish_print_commands.fish
@@ -1,5 +1,7 @@
function __fish_print_commands --description "Print a list of documented fish commands"
- if test -d $__fish_datadir/man/man1/
- find $__fish_datadir/man/man1/ -type f -name \*.1 -execdir basename '{}' .1 ';'
- end
+ if test -d $__fish_datadir/man/man1/
+ for file in $__fish_datadir/man/man1/**.1*
+ string replace -r '.*/' '' -- $file | string replace -r '.1(.gz)?$' ''
+ end
+ end
end
diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish
index 3d5ac0b6..265f9615 100644
--- a/share/functions/__fish_print_help.fish
+++ b/share/functions/__fish_print_help.fish
@@ -11,7 +11,7 @@ function __fish_print_help --description "Print help message for the specified f
end
# Do nothing if the file does not exist
- if not test -e "$__fish_datadir/man/man1/$item.1"
+ if not test -e "$__fish_datadir/man/man1/$item.1" -o -e "$__fish_datadir/man/man1/$item.1.gz"
return
end
@@ -39,7 +39,11 @@ function __fish_print_help --description "Print help message for the specified f
set cols (math $cols - 4) # leave a bit of space on the right
set rLL -rLL=$cols[1]n
end
- set help (nroff -man -c -t $rLL "$__fish_datadir/man/man1/$item.1" ^/dev/null)
+ if test -e "$__fish_datadir/man/man1/$item.1"
+ set help (nroff -man -c -t $rLL "$__fish_datadir/man/man1/$item.1" ^/dev/null)
+ else if test -e "$__fish_datadir/man/man1/$item.1.gz"
+ set help (gunzip -c "$__fish_datadir/man/man1/$item.1.gz" ^/dev/null | nroff -man -c -t $rLL ^/dev/null)
+ end
# The original implementation trimmed off the top 5 lines and bottom 3 lines
# from the nroff output. Perhaps that's reliable, but the magic numbers make
diff --git a/src/builtin_jobs.cpp b/src/builtin_jobs.cpp
index 406795aa..f5f7a059 100644
--- a/src/builtin_jobs.cpp
+++ b/src/builtin_jobs.cpp
@@ -204,7 +204,7 @@ int builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
while ((j = jobs.next())) {
// Ignore unconstructed jobs, i.e. ourself.
if ((j->flags & JOB_CONSTRUCTED) && !job_is_completed(j)) {
- builtin_jobs_print(j, mode, !streams.out_is_redirected, streams);
+ builtin_jobs_print(j, mode, !found && !streams.out_is_redirected, streams);
found = 1;
}
}
diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp
index cab9df03..67201975 100644
--- a/src/fish_indent.cpp
+++ b/src/fish_indent.cpp
@@ -348,7 +348,7 @@ int main(int argc, char *argv[]) {
output_type_ansi,
output_type_html
} output_type = output_type_plain_text;
- const char *output_location;
+ const char *output_location = "";
bool do_indent = true;
const char *short_opts = "+dhvwi";
@@ -410,6 +410,10 @@ int main(int argc, char *argv[]) {
wcstring src;
if (argc == 0) {
src = read_file(stdin);
+ if (output_type == output_type_file) {
+ fwprintf(stderr, _(L"You cannot use -w without providing the path to read from and write to."));
+ exit(1);
+ }
} else if (argc == 1) {
FILE *fh = fopen(*argv, "r");
if (fh) {
diff --git a/tests/jobs.err b/tests/jobs.err
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/jobs.err
diff --git a/tests/jobs.in b/tests/jobs.in
new file mode 100644
index 00000000..c32b9b37
--- /dev/null
+++ b/tests/jobs.in
@@ -0,0 +1,3 @@
+sleep 1 &
+sleep 1 &
+jobs -c
diff --git a/tests/jobs.out b/tests/jobs.out
new file mode 100644
index 00000000..702f017f
--- /dev/null
+++ b/tests/jobs.out
@@ -0,0 +1,3 @@
+Command
+sleep
+sleep
diff --git a/tests/jobs.status b/tests/jobs.status
new file mode 100644
index 00000000..573541ac
--- /dev/null
+++ b/tests/jobs.status
@@ -0,0 +1 @@
+0