aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-09-01 02:14:13 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-09-01 02:14:13 -0700
commitde5223db66ba36001020f7b3c2acda4303b927b3 (patch)
tree5f8b5cdf5d8975927e602337065e96fccf12af51
parentcc1395797e78a26583461333199181b4f8ec0b13 (diff)
Improve documentation and error reporting for elseif.
-rw-r--r--doc_src/if.txt13
-rw-r--r--parser.cpp9
-rw-r--r--share/functions/__fish_print_help.fish7
3 files changed, 19 insertions, 10 deletions
diff --git a/doc_src/if.txt b/doc_src/if.txt
index afad5384..aa43bdfb 100644
--- a/doc_src/if.txt
+++ b/doc_src/if.txt
@@ -1,7 +1,7 @@
\section if if - conditionally execute a command
\subsection if-synopsis Synopsis
-<tt>if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end</tt>
+<tt>if CONDITION; COMMANDS_TRUE...; [elseif CONDITION2; COMMANDS_TRUE2...;] [else; COMMANDS_FALSE...;] end</tt>
\subsection if-description Description
@@ -24,10 +24,13 @@ variable.
<pre>
if test -f foo.txt
echo foo.txt exists
+elseif test -f bar.txt
+ echo bar.txt exists
else
- echo foo.txt does not exist
+ echo foo.txt and bar.txt do not exist
end
-</pre>
-will print <tt>foo.txt exists</tt> if the file foo.txt
+</pre>will print <tt>foo.txt exists</tt> if the file foo.txt
exists and is a regular file, otherwise it will print
-<tt>foo.txt does not exist</tt>.
+<tt>bar.txt exists</tt> if the file bar.txt exists
+and is a regular file, otherwise it will print
+<tt>foo.txt and bar.txt do not exist</tt>.
diff --git a/parser.cpp b/parser.cpp
index b8818a9a..cbc3bd4d 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -146,7 +146,7 @@ The fish parser. Contains functions for parsing and evaluating code.
/**
Error when using else builtin outside of if block
*/
-#define INVALID_ELSE_ERR_MSG _( L"'else' builtin not inside of if block" )
+#define INVALID_ELSE_OR_ELSEIF_ERR_MSG _( L"'%ls' builtin not inside of if block" )
/**
Error when using end builtin outside of block
@@ -3293,9 +3293,9 @@ int parser_t::test( const wchar_t * buff,
}
/*
- Test that else is only used directly in an if-block
+ Test that else and elseif are only used directly in an if-block
*/
- if( command == L"else" )
+ if( command == L"else" || command == L"elseif" )
{
if( !count || block_type[count-1]!=IF )
{
@@ -3304,7 +3304,8 @@ int parser_t::test( const wchar_t * buff,
{
error( SYNTAX_ERROR,
tok_get_pos( &tok ),
- INVALID_ELSE_ERR_MSG );
+ INVALID_ELSE_OR_ELSEIF_ERR_MSG,
+ command.c_str());
print_errors( *out, prefix );
}
diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish
index 1ea7393d..07df075c 100644
--- a/share/functions/__fish_print_help.fish
+++ b/share/functions/__fish_print_help.fish
@@ -8,6 +8,11 @@ function __fish_print_help --description "Print help message for the specified f
case '*'
set item $argv[1]
end
+
+ # Do nothing if the file does not exist
+ if not test -e "$__fish_datadir/man/man1/$item.1"
+ return
+ end
# These two expressions take care of underlines (Should be italic)
set -l cmd1 s/_\x08'\(.\)'/(set_color --underline)\\1(set_color normal)/g
@@ -32,4 +37,4 @@ function __fish_print_help --description "Print help message for the specified f
# Filter and print help
printf "%s\n" $help| tail -n (expr $lines - 5) | head -n (expr $lines - 8) | sed $sed_cmd
-end \ No newline at end of file
+end