From ceba377ab82aecd920f2a361864850662b7d797f Mon Sep 17 00:00:00 2001 From: Grissiom Date: Wed, 13 Oct 2010 04:30:23 +0800 Subject: [PATCH 01/11] use is_interactive instead of isatty to test whether we are in interactive mode --- builtin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin.c b/builtin.c index 13694aacb..7feb7e0ee 100644 --- a/builtin.c +++ b/builtin.c @@ -2207,7 +2207,7 @@ static int builtin_read( wchar_t **argv ) /* Check if we should read interactively using \c reader_readline() */ - if( isatty(0) && builtin_stdin == 0 ) + if( is_interactive && builtin_stdin == 0 ) { wchar_t *line; From fa148bf59f9b418f3d64af848847f557930d3458 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Sun, 17 Oct 2010 01:39:52 +0800 Subject: [PATCH 02/11] break long lines --- parser.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/parser.c b/parser.c index 702392b69..36912fa8f 100644 --- a/parser.c +++ b/parser.c @@ -2319,8 +2319,12 @@ static void eval_job( tokenizer *tok ) j = job_create(); job_set_flag( j, JOB_FOREGROUND, 1 ); job_set_flag( j, JOB_TERMINAL, job_get_flag( j, JOB_CONTROL ) ); - job_set_flag( j, JOB_TERMINAL, job_get_flag( j, JOB_CONTROL ) && (!is_subshell && !is_event)); - job_set_flag( j, JOB_SKIP_NOTIFICATION, is_subshell || is_block || is_event || (!is_interactive)); + job_set_flag( j, JOB_TERMINAL, job_get_flag( j, JOB_CONTROL ) \ + && (!is_subshell && !is_event)); + job_set_flag( j, JOB_SKIP_NOTIFICATION, is_subshell \ + || is_block \ + || is_event \ + || (!is_interactive)); current_block->job = j; From e0ba91db3167159b1e818177d48afb34b89c00f0 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Mon, 22 Nov 2010 08:43:21 +0800 Subject: [PATCH 03/11] Revert "use is_interactive instead of isatty to test whether we are in interactive mode" This reverts commit ceba377ab82aecd920f2a361864850662b7d797f. --- builtin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin.c b/builtin.c index 7feb7e0ee..13694aacb 100644 --- a/builtin.c +++ b/builtin.c @@ -2207,7 +2207,7 @@ static int builtin_read( wchar_t **argv ) /* Check if we should read interactively using \c reader_readline() */ - if( is_interactive && builtin_stdin == 0 ) + if( isatty(0) && builtin_stdin == 0 ) { wchar_t *line; From 82f8c3834ee9fef74ab89a562eea3a22dcaf0d81 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Mon, 22 Nov 2010 19:05:06 +0800 Subject: [PATCH 04/11] Makefile: Provide PACKAGE_TARNAME for autoconf default docdir docdir was previously being set to "${prefix}/share/doc/${PACKAGE_NAME}" when it wasn't explicitely set on configuration using --docdir. Without this appearing in the Makefile, some files silently get silently installed directly into ${prefix}/share/doc instead within a fish subdirectory. I also added datarootdir to fix an autoconf warning, since autoconf normally would use it for the directory paths (e.g. docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}). The autoconf generated configure script has a hack to fix this, but states: "FIXME: This hack should be removed a few years after 2.60." --- Makefile.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.in b/Makefile.in index f52b8a405..2f09833da 100644 --- a/Makefile.in +++ b/Makefile.in @@ -31,6 +31,8 @@ # hallucinations. # +# Used by docdir +PACKAGE_TARNAME = @PACKAGE_TARNAME@ # # Programs @@ -46,6 +48,7 @@ INSTALL:=@INSTALL@ prefix = @prefix@ exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ datadir = @datadir@ bindir = @bindir@ mandir = @mandir@ From 6b243fbcd35f57633066d6d948845d8ad7818239 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Mon, 22 Nov 2010 19:36:42 +0800 Subject: [PATCH 05/11] eval: (eval false) should return an error status This also caused (isatty < /dev/null) to return 0 since it uses eval, and (ls | cat) to output using the classify indicator style since it uses isatty. This is how I found the bug. Reviewed-by: Grissiom --- share/functions/eval.fish | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/functions/eval.fish b/share/functions/eval.fish index 34c4e3aa3..aec8de27a 100644 --- a/share/functions/eval.fish +++ b/share/functions/eval.fish @@ -21,6 +21,8 @@ function eval -S -d "Evaluate parameters as a command" end echo begin\; $argv \;end eval2_inner \<\&3 3\<\&- | . 3<&0 + set -l res $status status --job-control $mode + return $res end From fefd17fe5e8ae629dff0ccb0565d0dcfb3a5efb0 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Tue, 23 Nov 2010 23:05:21 +0800 Subject: [PATCH 06/11] add test case for 6b243fbc --- tests/test1.in | 13 ++++++++++++- tests/test1.out | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test1.in b/tests/test1.in index 3b3ba25f3..9cf80a128 100644 --- a/tests/test1.in +++ b/tests/test1.in @@ -1,5 +1,5 @@ # -#Test aliases loops and conditionals +#Test aliases, loops, conditionals and some basic elements # for i in 1 2 #Comment on same line as command @@ -51,3 +51,14 @@ for i in Test for continue break and switch builtins problems; end end +set -l sta +if eval true + if eval false + set sta fail + else + set sta pass + end +else + set sta fail +end +echo Test 4 $sta diff --git a/tests/test1.out b/tests/test1.out index 64b65faa5..e0e258d4c 100644 --- a/tests/test1.out +++ b/tests/test1.out @@ -5,3 +5,4 @@ Test 2 pass Test pass Test 3 pass +Test 4 pass From 5fca92994ff94a0806413efe21f24f5f99b9e423 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Tue, 23 Nov 2010 23:37:09 +0800 Subject: [PATCH 07/11] help.fish: Fix the sed expression to find anchors with id or name Previously the expression only searched for anchors with a name attribute, but doxygen 1.7.1 is producing anchors with the id attribute instead. The sed expression allows both cases for compatibility. I also used single quotes for the sed expression to avoid escaping double quotes. Signed-off-by: Grissiom --- share/functions/help.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/functions/help.fish b/share/functions/help.fish index bd5360026..9531c103e 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -86,7 +86,7 @@ function help --description "Show help for the fish shell" # documentation. It's a bit of a hack, since it relies on the # Doxygen markup format to never change. - case (sed -n < $__fish_help_dir/commands.html -e "s/.*

.*/\1/p") + case (sed -n 's/.*

.*/\2/p' $__fish_help_dir/commands.html) set fish_help_page "commands.html\#$fish_help_item" case $help_topics set fish_help_page "index.html\#$fish_help_item" From 9f3a4d1640779d8adc4948445f0f863296e1a50d Mon Sep 17 00:00:00 2001 From: James Vega Date: Tue, 23 Nov 2010 23:45:30 +0800 Subject: [PATCH 08/11] Fix some spelling mistakes Fix spelling mistakes in various bits of the documentation. Signed-off-by: James Vega Signed-off-by: Grissiom --- doc_src/complete.txt | 2 +- doc_src/fish_indent.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc_src/complete.txt b/doc_src/complete.txt index dfc7cc910..f6d00a154 100644 --- a/doc_src/complete.txt +++ b/doc_src/complete.txt @@ -6,7 +6,7 @@ \subsection complete-description Description For an introduction to how to specify completions, see the section Writing your own completions of +href='index.html#completion-own'>Writing your own completions of the fish manual. - COMMAND is the name of the command for which to add a completion diff --git a/doc_src/fish_indent.txt b/doc_src/fish_indent.txt index 877290585..68d0647c9 100644 --- a/doc_src/fish_indent.txt +++ b/doc_src/fish_indent.txt @@ -1,4 +1,4 @@ -\section fish_indent fish_indent - indenter and prettyfier +\section fish_indent fish_indent - indenter and prettifier \subsection fish_indent-synopsis Synopsis fish_indent [options] From 364d3dbbf8de049ab48220de6322cf004457612b Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Wed, 24 Nov 2010 00:27:16 +0800 Subject: [PATCH 09/11] exec: Don't format status returned directly from builtin function The builtin function returns the raw status, which is not the same as the integer return by waitpid. Therefore, the WIF macros shouldn't be used for checking or obtaining the status. This bug can be seen by executing (eval false). The builtin eval function returns 1, but proc_format_status misinterprets it as a signal by checking WIFSIGNALED, so adds 128 to the status to return 129. Signed-off-by: Grissiom --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 13fb81b5f..2f5f8e656 100644 --- a/exec.c +++ b/exec.c @@ -1575,7 +1575,7 @@ void exec( job_t *j ) { debug( 3, L"Set status of %ls to %d using short circut", j->command, p->status ); - int status = proc_format_status(p->status); + int status = p->status; proc_set_last_status( job_get_flag( j, JOB_NEGATE )?(!status):status ); } break; From 9b97c55546dfae247f0bc2f785552243fdc3738a Mon Sep 17 00:00:00 2001 From: Grissiom Date: Wed, 24 Nov 2010 00:35:56 +0800 Subject: [PATCH 10/11] add test case for 364d3dbbf8d --- tests/test1.in | 11 +++++++++++ tests/test1.out | 1 + 2 files changed, 12 insertions(+) diff --git a/tests/test1.in b/tests/test1.in index 9cf80a128..ff3ef7788 100644 --- a/tests/test1.in +++ b/tests/test1.in @@ -62,3 +62,14 @@ else set sta fail end echo Test 4 $sta + +function test_builtin_status + return 1 +end +test_builtin_status +if [ $status -eq 1 ] + set sta pass +else + set sta fail +end +echo Test 5 $sta diff --git a/tests/test1.out b/tests/test1.out index e0e258d4c..f20a722f0 100644 --- a/tests/test1.out +++ b/tests/test1.out @@ -6,3 +6,4 @@ Test 2 pass Test pass Test 3 pass Test 4 pass +Test 5 pass From 4f9b07e979b442b7e6f8ccbfcf559590b02a5b4e Mon Sep 17 00:00:00 2001 From: James Vega Date: Wed, 24 Nov 2010 00:49:15 +0800 Subject: [PATCH 11/11] Allow fish_greeting to be NULL or an array Treat fish_greeting as a whole when show up the greeting messages. And the user may want to set fish_greeting to an null value or an array. This requires that the variable be quoted when used as an argument for switch in __fish_config_interactive. Signed-off-by: James Vega [modified the commit message] Signed-off-by: Grissiom --- share/functions/__fish_config_interactive.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index e2ace3f0c..7ec8215ed 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -150,7 +150,7 @@ function __fish_config_interactive -d "Initializations that should be performed fish_greeting else if set -q fish_greeting - switch $fish_greeting + switch "$fish_greeting" case '' # If variable is empty, don't print anything, saves us a fork