mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Update documentation display code to run roff on the client system instead of pregenerating documentation and compiling it into program binaries
darcs-hash:20061117162438-ac50b-5c4c7f0bd8bf53a16e16ecfead9569e642b7160f.gz
This commit is contained in:
parent
b30886228c
commit
1b71f91a01
36 changed files with 332 additions and 269 deletions
101
Makefile.in
101
Makefile.in
|
@ -96,7 +96,7 @@ FISH_OBJS := function.o builtin.o complete.o env.o exec.o expand.o \
|
|||
# Additional files used by builtin.o
|
||||
#
|
||||
|
||||
BUILTIN_FILES := builtin_help.c builtin_set.c builtin_commandline.c \
|
||||
BUILTIN_FILES := builtin_set.c builtin_commandline.c \
|
||||
builtin_ulimit.c builtin_complete.c builtin_jobs.c
|
||||
|
||||
|
||||
|
@ -119,16 +119,17 @@ FISH_TESTS_OBJS := $(FISH_OBJS) fish_tests.o
|
|||
# All objects that the system needs to build fishd
|
||||
#
|
||||
|
||||
FISHD_OBJS := fishd.o env_universal_common.o wutil.o \
|
||||
doc_src/fishd.o common.o
|
||||
FISHD_OBJS := fishd.o env_universal_common.o wutil.o print_help.o \
|
||||
common.o
|
||||
|
||||
|
||||
#
|
||||
# All objects needed to build mimedb
|
||||
#
|
||||
|
||||
MIME_OBJS := mimedb.o xdgmimealias.o xdgmime.o xdgmimeglob.o \
|
||||
xdgmimeint.o xdgmimemagic.o xdgmimeparent.o wutil.o common.o
|
||||
MIME_OBJS := mimedb.o print_help.o xdgmimealias.o xdgmime.o \
|
||||
xdgmimeglob.o xdgmimeint.o xdgmimemagic.o xdgmimeparent.o wutil.o \
|
||||
common.o
|
||||
|
||||
|
||||
#
|
||||
|
@ -205,10 +206,10 @@ DOC_SRC_DIR_FILES := doc_src/Doxyfile.in doc_src/index.hdr \
|
|||
|
||||
MAIN_DIR_FILES := Doxyfile Doxyfile.user Makefile.in configure \
|
||||
configure.ac config.h.in install-sh set_color.c count.c \
|
||||
key_reader.c gen_hdr.sh gen_hdr2.c $(MIME_OBJS:.o=.h) \
|
||||
key_reader.c $(MIME_OBJS:.o=.h) \
|
||||
$(MIME_OBJS:.o=.c) $(FISH_OBJS:.o=.h) $(BUILTIN_FILES) \
|
||||
$(COMMON_FILES) $(COMMON_FILES:.c=.h) $(FISH_OBJS:.o=.c) \
|
||||
builtin_help.hdr fish.spec.in INSTALL README user_doc.head.html \
|
||||
fish.spec.in INSTALL README user_doc.head.html \
|
||||
xsel-0.9.6.tar ChangeLog config.sub config.guess fish_tests.c \
|
||||
main.c fish_pager.c fishd.c seq.in
|
||||
|
||||
|
@ -312,6 +313,7 @@ debug:
|
|||
# User documentation, describing the features of the fish shell.
|
||||
#
|
||||
|
||||
|
||||
user_doc: doc_src/index.hdr doc_src/design.hdr doc_src/license.hdr doc_src/faq.hdr Doxyfile.user user_doc.head.html $(CMD_DOC_SRC) $(BUILTIN_DOC_SRC)
|
||||
$(MAKE) doc.h # Depend on the sources (*.hdr) and manually make the intermediate as needed
|
||||
doxygen Doxyfile.user
|
||||
|
@ -322,7 +324,7 @@ user_doc: doc_src/index.hdr doc_src/design.hdr doc_src/license.hdr doc_src/faq.h
|
|||
# Source code documentation. Also includes user documentation.
|
||||
#
|
||||
|
||||
doc: *.h *.c doc.h Doxyfile builtin_help.c
|
||||
doc: *.h *.c doc.h Doxyfile
|
||||
doxygen;
|
||||
|
||||
|
||||
|
@ -467,8 +469,7 @@ common.o: $(COMMON_FILES)
|
|||
|
||||
#
|
||||
# Generate the internal help functions by making doxygen create
|
||||
# man-pages which are then converted into C code. The convertion path
|
||||
# looks like this:
|
||||
# man-pages. The convertion path looks like this:
|
||||
#
|
||||
# .txt file
|
||||
# ||
|
||||
|
@ -480,26 +481,20 @@ common.o: $(COMMON_FILES)
|
|||
# (doxygen)
|
||||
# ||
|
||||
# \/
|
||||
# man file
|
||||
# roff file
|
||||
# ||
|
||||
# (man)
|
||||
# (__fish_print_help)
|
||||
# ||
|
||||
# \/
|
||||
# formated text
|
||||
# with escape
|
||||
# sequences
|
||||
# ||
|
||||
# \/
|
||||
# (gen_hdr2)
|
||||
# ||
|
||||
# \/
|
||||
# .c file
|
||||
#
|
||||
# Which is an awful, clunky and ugly way of producing
|
||||
# documentation. There ought to be something simpler.
|
||||
#
|
||||
# There ought to be something simpler.
|
||||
#
|
||||
|
||||
doc_src/builtin_doc: $(BUILTIN_DOC_SRC) doc_src/count.txt builtin_help.hdr $(CMD_DOC_SRC)
|
||||
doc_src/builtin_doc: $(BUILTIN_DOC_SRC) doc_src/count.txt $(CMD_DOC_SRC)
|
||||
for i in $(BUILTIN_DOC_SRC) $(CMD_DOC_SRC); do \
|
||||
FILE=doc_src/`basename $$i .txt`.doxygen; \
|
||||
echo "/** \page" `basename $$i .txt` >$$FILE; \
|
||||
|
@ -514,37 +509,6 @@ doc_src/builtin_doc: $(BUILTIN_DOC_SRC) doc_src/count.txt builtin_help.hdr $(CMD
|
|||
done
|
||||
touch doc_src/builtin_doc
|
||||
|
||||
builtin_help.c: doc_src/builtin_doc gen_hdr.sh
|
||||
$(MAKE) gen_hdr2 # Don't depend on gen_hdr2, because then we would need to rebuild the docs whenever we use a fresh tarball
|
||||
cp builtin_help.hdr builtin_help.c;
|
||||
if test -x gen_hdr.sh; then true; else chmod 755 gen_hdr.sh; fi
|
||||
for i in $(BUILTIN_DOC_HDR) doc_src/count.doxygen ; do \
|
||||
echo ' hash_put( &tbl, L"'`basename $$i .doxygen`'",' >>$@; \
|
||||
./gen_hdr.sh $$i >>$@; \
|
||||
printf " );\n\n" >>$@; \
|
||||
done;
|
||||
echo "}" >>builtin_help.c
|
||||
|
||||
|
||||
#
|
||||
# Generate help texts for external fish commands, like set_color and
|
||||
# mimedb.
|
||||
#
|
||||
|
||||
%.c : %.doxygen
|
||||
$(MAKE) gen_hdr2 builtin_help.c # These should really be filed as dependencis for %.c above instead, but that seems to confuse make
|
||||
echo "// This file was automatically generated, do not edit" >$@
|
||||
echo "#include <stdlib.h>" >>$@
|
||||
echo "#include <stdio.h>" >>$@
|
||||
echo >>$@
|
||||
echo "void print_help()" >>$@
|
||||
echo "{" >>$@
|
||||
echo ' printf( "%s",' >>$@
|
||||
chmod 755 gen_hdr.sh
|
||||
./gen_hdr.sh $*.doxygen >>$@
|
||||
echo ");" >>$@
|
||||
echo "}" >>$@
|
||||
|
||||
#
|
||||
# The build rules for installing/uninstalling fish
|
||||
#
|
||||
|
@ -614,6 +578,7 @@ install-force: all install-translations
|
|||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/completions
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/functions
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/man
|
||||
$(INSTALL) -m 644 etc/config.fish $(DESTDIR)$(sysconfdir)/fish/
|
||||
$(INSTALL) -m 644 share/config.fish $(DESTDIR)$(datadir)/fish/
|
||||
$(INSTALL) -m 644 share/config_interactive.fish $(DESTDIR)$(datadir)/fish/
|
||||
|
@ -623,6 +588,9 @@ install-force: all install-translations
|
|||
for i in $(FUNCTIONS_DIR_FILES); do \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/functions/; \
|
||||
done;
|
||||
for i in share/man/*.1; do \
|
||||
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/man/; \
|
||||
done;
|
||||
$(INSTALL) -m 644 etc/fish_inputrc $(DESTDIR)$(sysconfdir)/fish/fish_inputrc;
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(docdir)
|
||||
for i in user_doc/html/* ChangeLog; do \
|
||||
|
@ -755,8 +723,8 @@ fish_tests: $(FISH_TESTS_OBJS)
|
|||
# mimedb does not need any libraries, so we don't use LDFLAGS here.
|
||||
#
|
||||
|
||||
mimedb: $(MIME_OBJS) doc_src/mimedb.o
|
||||
$(CC) $(MIME_OBJS) doc_src/mimedb.o $(LDFLAGS) -o $@
|
||||
mimedb: $(MIME_OBJS)
|
||||
$(CC) $(MIME_OBJS) $(LDFLAGS) -o $@
|
||||
|
||||
|
||||
#
|
||||
|
@ -773,8 +741,8 @@ count: count.o
|
|||
# Build the set_color program
|
||||
#
|
||||
|
||||
set_color: set_color.o doc_src/set_color.o common.o
|
||||
$(CC) set_color.o doc_src/set_color.o common.o wutil.o $(LDFLAGS) -o $@
|
||||
set_color: set_color.o print_help.o common.o
|
||||
$(CC) set_color.o print_help.o common.o wutil.o $(LDFLAGS) -o $@
|
||||
|
||||
|
||||
#
|
||||
|
@ -801,7 +769,6 @@ depend:
|
|||
./config.status
|
||||
.PHONY: depend
|
||||
|
||||
|
||||
#
|
||||
# Copy all the source files into a new directory and use tar to create
|
||||
# an archive from it. Simplest way I could think of to make an archive
|
||||
|
@ -820,6 +787,7 @@ fish-@PACKAGE_VERSION@.tar: $(DOC_SRC_DIR_FILES) $(MAIN_DIR_FILES) $(ETC_DIR_FIL
|
|||
$(INSTALL) -d fish-@PACKAGE_VERSION@/share
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/completions
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/functions
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/man
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/tests
|
||||
$(INSTALL) -d fish-@PACKAGE_VERSION@/po
|
||||
cp -f $(DOC_SRC_DIR_FILES) fish-@PACKAGE_VERSION@/doc_src
|
||||
|
@ -830,6 +798,7 @@ fish-@PACKAGE_VERSION@.tar: $(DOC_SRC_DIR_FILES) $(MAIN_DIR_FILES) $(ETC_DIR_FIL
|
|||
cp -f $(FUNCTIONS_DIR_FILES) fish-@PACKAGE_VERSION@/share/functions/
|
||||
cp -f $(TESTS_DIR_FILES) fish-@PACKAGE_VERSION@/tests/
|
||||
cp -f $(TRANSLATIONS_SRC) fish-@PACKAGE_VERSION@/po/
|
||||
cp -f doc_src/builtin_doc/man/man1/*.1 fish-@PACKAGE_VERSION@/share/man/
|
||||
cp -rf user_doc fish-@PACKAGE_VERSION@/
|
||||
cp -rf doc_src/builtin_doc fish-@PACKAGE_VERSION@/doc_src/
|
||||
tar -c fish-@PACKAGE_VERSION@ >fish-@PACKAGE_VERSION@.tar
|
||||
|
@ -908,7 +877,7 @@ distclean: clean
|
|||
clean:
|
||||
rm -f *.o doc.h doc.tmp doc_src/*.doxygen doc_src/*.c doc_src/*.o doc_src/commands.hdr
|
||||
rm -f tests/tmp.err tests/tmp.out tests/tmp.status tests/foo.txt
|
||||
rm -f tokenizer_test fish key_reader set_color gen_hdr2 mimedb
|
||||
rm -f tokenizer_test fish key_reader set_color mimedb
|
||||
rm -f fishd fish_pager count fish_tests
|
||||
rm -f fish-@PACKAGE_VERSION@.tar
|
||||
rm -f fish-@PACKAGE_VERSION@.tar.gz
|
||||
|
@ -926,8 +895,8 @@ builtin.o: config.h fallback.h util.h wutil.h builtin.h function.h complete.h
|
|||
builtin.o: proc.h io.h parser.h event.h reader.h env.h common.h wgetopt.h
|
||||
builtin.o: sanity.h tokenizer.h wildcard.h input_common.h input.h intern.h
|
||||
builtin.o: signal.h halloc.h halloc_util.h parse_util.h expand.h path.h
|
||||
builtin.o: builtin_help.c builtin_set.c builtin_commandline.c
|
||||
builtin.o: builtin_complete.c builtin_ulimit.c builtin_jobs.c
|
||||
builtin.o: builtin_set.c builtin_commandline.c builtin_complete.c
|
||||
builtin.o: builtin_ulimit.c builtin_jobs.c
|
||||
builtin_commandline.o: config.h signal.h fallback.h util.h wutil.h builtin.h
|
||||
builtin_commandline.o: common.h wgetopt.h reader.h proc.h io.h parser.h
|
||||
builtin_commandline.o: event.h tokenizer.h input_common.h input.h
|
||||
|
@ -935,7 +904,6 @@ builtin_commandline.o: parse_util.h
|
|||
builtin_complete.o: config.h signal.h fallback.h util.h wutil.h builtin.h
|
||||
builtin_complete.o: common.h complete.h wgetopt.h parser.h proc.h io.h
|
||||
builtin_complete.o: event.h reader.h
|
||||
builtin_help.o: config.h util.h common.h halloc_util.h
|
||||
builtin_jobs.o: config.h fallback.h util.h wutil.h builtin.h proc.h io.h
|
||||
builtin_jobs.o: parser.h event.h common.h wgetopt.h
|
||||
builtin_set.o: config.h signal.h fallback.h util.h wutil.h builtin.h env.h
|
||||
|
@ -960,8 +928,7 @@ event.o: config.h signal.h fallback.h util.h wutil.h function.h proc.h io.h
|
|||
event.o: parser.h event.h common.h halloc_util.h
|
||||
exec.o: config.h signal.h fallback.h util.h common.h wutil.h proc.h io.h
|
||||
exec.o: exec.h parser.h event.h builtin.h function.h env.h wildcard.h
|
||||
exec.o: sanity.h expand.h env_universal.h env_universal_common.h halloc.h
|
||||
exec.o: halloc_util.h parse_util.h
|
||||
exec.o: sanity.h expand.h halloc.h halloc_util.h parse_util.h
|
||||
expand.o: config.h signal.h fallback.h util.h common.h wutil.h env.h proc.h
|
||||
expand.o: io.h parser.h event.h expand.h wildcard.h exec.h tokenizer.h
|
||||
expand.o: complete.h parse_util.h halloc.h halloc_util.h
|
||||
|
@ -976,7 +943,7 @@ fish_tests.o: reader.h builtin.h function.h complete.h wutil.h env.h expand.h
|
|||
fish_tests.o: parser.h event.h tokenizer.h output.h exec.h halloc_util.h
|
||||
function.o: config.h signal.h wutil.h fallback.h util.h function.h proc.h
|
||||
function.o: io.h parser.h event.h common.h intern.h reader.h parse_util.h
|
||||
function.o: env.h expand.h
|
||||
function.o: env.h expand.h halloc.h halloc_util.h
|
||||
halloc.o: config.h fallback.h util.h common.h halloc.h
|
||||
halloc_util.o: config.h fallback.h util.h common.h halloc.h
|
||||
highlight.o: config.h signal.h fallback.h util.h wutil.h highlight.h
|
||||
|
@ -1011,7 +978,7 @@ parser.o: env_universal_common.h intern.h parse_util.h halloc.h halloc_util.h
|
|||
parser.o: path.h
|
||||
parse_util.o: config.h fallback.h util.h wutil.h common.h tokenizer.h
|
||||
parse_util.o: parse_util.h expand.h intern.h exec.h proc.h io.h env.h
|
||||
parse_util.o: wildcard.h halloc_util.h
|
||||
parse_util.o: signal.h wildcard.h halloc_util.h
|
||||
path.o: config.h fallback.h util.h common.h env.h wutil.h halloc.h
|
||||
path.o: halloc_util.h path.h expand.h
|
||||
proc.o: config.h signal.h fallback.h util.h wutil.h proc.h io.h common.h
|
||||
|
@ -1024,8 +991,8 @@ reader.o: function.h output.h screen.h parse_util.h
|
|||
sanity.o: config.h signal.h fallback.h util.h common.h sanity.h proc.h io.h
|
||||
sanity.o: history.h reader.h kill.h wutil.h
|
||||
screen.o: config.h fallback.h common.h util.h wutil.h output.h highlight.h
|
||||
screen.o: screen.h
|
||||
set_color.o: config.h fallback.h
|
||||
screen.o: screen.h env.h
|
||||
set_color.o: config.h fallback.h print_help.h
|
||||
signal.o: config.h signal.h common.h util.h fallback.h wutil.h event.h
|
||||
signal.o: reader.h proc.h io.h
|
||||
test.o: stringtab.h
|
||||
|
|
88
builtin.c
88
builtin.c
|
@ -60,6 +60,7 @@
|
|||
#include "intern.h"
|
||||
#include "event.h"
|
||||
#include "signal.h"
|
||||
#include "exec.h"
|
||||
|
||||
#include "halloc.h"
|
||||
#include "halloc_util.h"
|
||||
|
@ -193,10 +194,53 @@ static int count_char( const wchar_t *str, wchar_t c )
|
|||
|
||||
*/
|
||||
|
||||
wchar_t *builtin_help_get( const wchar_t *name )
|
||||
{
|
||||
array_list_t lst;
|
||||
string_buffer_t cmd;
|
||||
wchar_t *name_esc;
|
||||
|
||||
static string_buffer_t *out = 0;
|
||||
int i;
|
||||
|
||||
al_init( &lst );
|
||||
sb_init( &cmd );
|
||||
|
||||
if( !out )
|
||||
{
|
||||
out = sb_halloc( global_context );
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_clear( out );
|
||||
}
|
||||
|
||||
name_esc = escape( name, 1 );
|
||||
sb_printf( &cmd, L"__fish_print_help %ls", name_esc );
|
||||
|
||||
|
||||
exec_subshell( (wchar_t *)cmd.buff, &lst );
|
||||
|
||||
for( i=0; i<al_get_count( &lst); i++ )
|
||||
{
|
||||
sb_append( out, (wchar_t *)al_get( &lst, i ) );
|
||||
sb_append( out, L"\n" );
|
||||
}
|
||||
|
||||
al_destroy( &lst );
|
||||
sb_destroy( &cmd );
|
||||
free( name_esc );
|
||||
|
||||
|
||||
return (wchar_t *)out->buff;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void builtin_print_help( wchar_t *cmd, string_buffer_t *b )
|
||||
{
|
||||
const char *h;
|
||||
|
||||
const wchar_t *h;
|
||||
|
||||
if( b == sb_err )
|
||||
{
|
||||
|
@ -209,14 +253,17 @@ static void builtin_print_help( wchar_t *cmd, string_buffer_t *b )
|
|||
if( !h )
|
||||
return;
|
||||
|
||||
wchar_t *str = str2wcs( h );
|
||||
wchar_t *str = wcsdup( h );
|
||||
if( str )
|
||||
{
|
||||
|
||||
if( is_interactive && !builtin_out_redirect && b==sb_err)
|
||||
{
|
||||
|
||||
/* Interactive mode help to screen - only print synopsis if the rest won't fit */
|
||||
/*
|
||||
Interactive mode help to screen - only print synopsis if
|
||||
the rest won't fit
|
||||
*/
|
||||
|
||||
int screen_height, lines;
|
||||
|
||||
|
@ -226,9 +273,27 @@ static void builtin_print_help( wchar_t *cmd, string_buffer_t *b )
|
|||
{
|
||||
wchar_t *pos;
|
||||
int cut=0;
|
||||
int i;
|
||||
|
||||
/* Find first empty line */
|
||||
for( pos=str; *pos; pos++ )
|
||||
/*
|
||||
First move down 4 lines
|
||||
*/
|
||||
|
||||
pos = str;
|
||||
for( i=0; i<4; i++ )
|
||||
{
|
||||
pos = wcschr( pos+1, L'\n' );
|
||||
if( !pos )
|
||||
break;
|
||||
}
|
||||
|
||||
if( pos )
|
||||
{
|
||||
|
||||
/*
|
||||
Then find the next empty line
|
||||
*/
|
||||
for( ; *pos; pos++ )
|
||||
{
|
||||
if( *pos == L'\n' )
|
||||
{
|
||||
|
@ -248,17 +313,27 @@ static void builtin_print_help( wchar_t *cmd, string_buffer_t *b )
|
|||
}
|
||||
if( is_empty )
|
||||
{
|
||||
*(pos+1)=L'\0';
|
||||
/*
|
||||
And cut it
|
||||
*/
|
||||
*(pos2+1)=L'\0';
|
||||
cut = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
We did not find a good place to cut message to
|
||||
shorten it - so we make sure we don't print
|
||||
anything.
|
||||
*/
|
||||
if( !cut )
|
||||
{
|
||||
*str = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +362,6 @@ static void builtin_print_help( wchar_t *cmd, string_buffer_t *b )
|
|||
*/
|
||||
|
||||
|
||||
#include "builtin_help.c"
|
||||
#include "builtin_set.c"
|
||||
#include "builtin_commandline.c"
|
||||
#include "builtin_complete.c"
|
||||
|
|
|
@ -164,12 +164,10 @@ const wchar_t *builtin_complete_get_temporary_buffer();
|
|||
|
||||
|
||||
/**
|
||||
Return the help text for the specified builtin command. Use
|
||||
non-wide characters since wide characters have some issues with
|
||||
string formating escape sequences sometimes.
|
||||
Return the help text for the specified builtin command.
|
||||
|
||||
\param cmd The command for which to obtain help text
|
||||
*/
|
||||
char *builtin_help_get( const wchar_t *cmd );
|
||||
wchar_t *builtin_help_get( const wchar_t *cmd );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/** \file builtin_help.c
|
||||
|
||||
Functions for printing usage information of builtin commands. This
|
||||
file is automatically generated from the file builtin_help.hdr and
|
||||
various help files in the doc_src directory.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "common.h"
|
||||
#include "halloc_util.h"
|
||||
|
||||
/**
|
||||
Hashtable storing the help text
|
||||
*/
|
||||
static hash_table_t tbl;
|
||||
|
||||
static void builtin_help_init();
|
||||
|
||||
char *builtin_help_get( const wchar_t *cmd )
|
||||
{
|
||||
builtin_help_init();
|
||||
|
||||
return (char *)hash_get( &tbl, (void *)cmd );
|
||||
}
|
||||
|
||||
/**
|
||||
Initialize help hash table. Don't invoke it manually,
|
||||
it is called by builtin_help_get automatically.
|
||||
*/
|
||||
static void builtin_help_init()
|
||||
{
|
||||
static int is_help_init = 0;
|
||||
if( is_help_init )
|
||||
return;
|
||||
is_help_init=1;
|
||||
halloc_register_function( global_context, (void (*)(void *))&hash_destroy, &tbl );
|
||||
hash_init( &tbl, &hash_wcs_func, &hash_wcs_cmp );
|
15
doc_src/alias.txt
Normal file
15
doc_src/alias.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
\section alias alias - create a function
|
||||
|
||||
\subsection alias-synopsis Synopsis
|
||||
<tt>alias NAME DEFINITION</tt><br/>
|
||||
<tt>alias NAME=DEFINITION</tt>
|
||||
|
||||
\subsection alias-description Description
|
||||
|
||||
Alias is a shellscript wrapper around the function builtin.
|
||||
It exists for backwards compatibility with Posix
|
||||
shells. For other uses, it is recommended to define a <a
|
||||
href='#function'>function</a>.
|
||||
|
||||
- NAME is the name of the function to define
|
||||
- DEFINITION is the body of the function. The string " $argv" will be appended to the body.
|
15
doc_src/math.txt
Normal file
15
doc_src/math.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
\section math math - Perform mathematics calculations
|
||||
|
||||
\subsection math-synopsis Synopsis
|
||||
<tt>math EXPRESSION</tt>
|
||||
|
||||
\subsection math-description Description
|
||||
|
||||
math is used to perform mathematical calcualtions. It is only a very
|
||||
thin wrapper for the bc program, that makes it possible to specify an
|
||||
expression from the commandline without using non-standard extensions
|
||||
or a pipeline. Simply use a command like <code>math 1+1</code>.
|
||||
|
||||
For a description of the syntax supported by math, see the manual for
|
||||
the bc program.
|
19
exec.c
19
exec.c
|
@ -802,10 +802,6 @@ void exec( job_t *j )
|
|||
pipe_write.next=0;
|
||||
pipe_write.param1.pipe_fd[0]=pipe_write.param1.pipe_fd[1]=-1;
|
||||
|
||||
|
||||
|
||||
//fwprintf( stderr, L"Run command %ls\n", j->command );
|
||||
|
||||
j->io = io_add( j->io, &pipe_write );
|
||||
|
||||
signal_block();
|
||||
|
@ -918,6 +914,12 @@ void exec( job_t *j )
|
|||
const wchar_t * orig_def;
|
||||
wchar_t * def=0;
|
||||
|
||||
/*
|
||||
Calls to function_get_definition might need to
|
||||
source a file as a part of autoloading, hence there
|
||||
must be no blocks.
|
||||
*/
|
||||
|
||||
signal_unblock();
|
||||
orig_def = function_get_definition( p->argv[0] );
|
||||
signal_block();
|
||||
|
@ -1042,7 +1044,8 @@ void exec( job_t *j )
|
|||
}
|
||||
else
|
||||
{
|
||||
builtin_push_io( builtin_stdin );
|
||||
int old_out = builtin_out_redirect;
|
||||
int old_err = builtin_err_redirect;
|
||||
|
||||
/*
|
||||
Since this may be the foreground job, and since
|
||||
|
@ -1059,8 +1062,11 @@ void exec( job_t *j )
|
|||
to make exec handle things.
|
||||
*/
|
||||
|
||||
builtin_push_io( builtin_stdin );
|
||||
|
||||
builtin_out_redirect = has_fd( j->io, 1 );
|
||||
builtin_err_redirect = has_fd( j->io, 2 );
|
||||
|
||||
fg = job_get_flag( j, JOB_FOREGROUND );
|
||||
job_set_flag( j, JOB_FOREGROUND, 0 );
|
||||
|
||||
|
@ -1068,6 +1074,9 @@ void exec( job_t *j )
|
|||
|
||||
p->status = builtin_run( p->argv );
|
||||
|
||||
builtin_out_redirect=old_out;
|
||||
builtin_err_redirect=old_err;
|
||||
|
||||
signal_block();
|
||||
|
||||
/*
|
||||
|
|
|
@ -150,6 +150,10 @@ fi
|
|||
%dir %_datadir/fish/functions
|
||||
%_datadir/fish/functions/*.fish
|
||||
|
||||
# Documentation for builtins and shellscript functions
|
||||
%dir %_datadir/fish/man
|
||||
%_datadir/fish/man/*.1
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
8
fishd.c
8
fishd.c
|
@ -73,6 +73,7 @@ time the original barrier request was sent have been received.
|
|||
#include "halloc.h"
|
||||
#include "halloc_util.h"
|
||||
#include "path.h"
|
||||
#include "print_help.h"
|
||||
|
||||
/**
|
||||
Maximum length of socket filename
|
||||
|
@ -140,11 +141,6 @@ static int sock;
|
|||
*/
|
||||
static int quit=0;
|
||||
|
||||
/**
|
||||
Dynamically generated function, made from the documentation in doc_src.
|
||||
*/
|
||||
void print_help();
|
||||
|
||||
/**
|
||||
Constructs the fish socket filename
|
||||
*/
|
||||
|
@ -620,7 +616,7 @@ int main( int argc, char ** argv )
|
|||
break;
|
||||
|
||||
case 'h':
|
||||
print_help();
|
||||
print_help( argv[0], 1 );
|
||||
exit(0);
|
||||
|
||||
case 'v':
|
||||
|
|
12
gen_hdr.sh
12
gen_hdr.sh
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This little script calls the man command to render a manual page and
|
||||
# pipes the result into the gen_hdr2 program to convert the output
|
||||
# into a C string literal.
|
||||
|
||||
# NAME is the name of the function we are generating documentation for.
|
||||
NAME=`basename $1 .doxygen`
|
||||
|
||||
# Render the page
|
||||
nroff -man doc_src/builtin_doc/man/man1/${NAME}.1 | col -b | cat -s | sed -e '$d' | ./gen_hdr2
|
||||
|
76
gen_hdr2.c
76
gen_hdr2.c
|
@ -1,76 +0,0 @@
|
|||
/** \file gen_hdr2.c
|
||||
A program that reads data from stdin and outputs it as a C string.
|
||||
|
||||
It is used as a part of the build process to generate help texts
|
||||
for the built in commands.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
/**
|
||||
The main function, does all the work
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
int line = 0;
|
||||
printf( "\t\t\"" );
|
||||
int c;
|
||||
int count=0;
|
||||
while( (c=getchar()) != EOF )
|
||||
{
|
||||
if( c == '\n' )
|
||||
line++;
|
||||
|
||||
if( line > 4 )
|
||||
break;
|
||||
}
|
||||
|
||||
while( (c=getchar()) != EOF )
|
||||
{
|
||||
if( (c >= 'a' && c <= 'z' ) ||
|
||||
(c >= 'A' && c <= 'Z' ) ||
|
||||
(c >= '0' && c <= '9' ) ||
|
||||
( strchr(" ,.!;:-_#$%&(){}[]<>=?+-*/'",c) != 0) )
|
||||
{
|
||||
count++;
|
||||
putchar(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case '\n':
|
||||
printf( "\\n" );
|
||||
printf( "\"\n\t\t\"" );
|
||||
count =0;
|
||||
break;
|
||||
case '\t':
|
||||
printf( "\\t" );
|
||||
count +=2;
|
||||
break;
|
||||
case '\r':
|
||||
printf( "\\r" );
|
||||
count +=2;
|
||||
break;
|
||||
|
||||
case '\"':
|
||||
case '\\':
|
||||
printf( "\\%c",c );
|
||||
count +=2;
|
||||
break;
|
||||
|
||||
default:
|
||||
count +=7;
|
||||
printf( "\\x%02x\" \"", c );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( count > 60 )
|
||||
{
|
||||
count=0;
|
||||
printf( "\"\n\t\t\"" );
|
||||
}
|
||||
}
|
||||
printf( "\"" );
|
||||
return 0;
|
||||
}
|
9
mimedb.c
9
mimedb.c
|
@ -46,6 +46,7 @@ license. Read the source code of the library for more information.
|
|||
#include "xdgmime.h"
|
||||
#include "fallback.h"
|
||||
#include "util.h"
|
||||
#include "print_help.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -140,10 +141,6 @@ static int launch_pos=0;
|
|||
*/
|
||||
#define _(string) gettext(string)
|
||||
|
||||
/**
|
||||
Dynamically generated function, made from the documentation in doc_src.
|
||||
*/
|
||||
void print_help();
|
||||
|
||||
/**
|
||||
Call malloc, set error flag and print message on failure
|
||||
|
@ -1258,7 +1255,7 @@ int main (int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'h':
|
||||
print_help();
|
||||
print_help( argv[0], 1 );
|
||||
exit(0);
|
||||
|
||||
case 'v':
|
||||
|
@ -1274,7 +1271,7 @@ int main (int argc, char *argv[])
|
|||
if( ( output_type == LAUNCH )&&(input_type==MIMETYPE))
|
||||
{
|
||||
fprintf( stderr, _("%s: Can not launch a mimetype\n"), MIMEDB );
|
||||
print_help();
|
||||
print_help( argv[0], 2 );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -885,7 +885,6 @@ static int parse_util_load_internal( const wchar_t *cmd,
|
|||
if( on_load )
|
||||
on_load(cmd );
|
||||
|
||||
|
||||
/*
|
||||
Source the completion file for the specified completion
|
||||
*/
|
||||
|
|
16
parser.c
16
parser.c
|
@ -2564,7 +2564,7 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type )
|
|||
|
||||
if( (!error_code) && (!exit_status()) && (!proc_get_last_status()) )
|
||||
{
|
||||
char *h;
|
||||
wchar_t *h;
|
||||
|
||||
//debug( 2, L"Status %d\n", proc_get_last_status() );
|
||||
|
||||
|
@ -2576,7 +2576,7 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type )
|
|||
|
||||
h = builtin_help_get( L"end" );
|
||||
if( h )
|
||||
fwprintf( stderr, L"%s", h );
|
||||
fwprintf( stderr, L"%ls", h );
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -3090,7 +3090,7 @@ int parser_test( const wchar_t * buff,
|
|||
|
||||
if( out )
|
||||
{
|
||||
char *h;
|
||||
wchar_t *h;
|
||||
|
||||
error( SYNTAX_ERROR,
|
||||
tok_get_pos( &tok ),
|
||||
|
@ -3099,7 +3099,7 @@ int parser_test( const wchar_t * buff,
|
|||
print_errors( out, prefix);
|
||||
h = builtin_help_get( L"case" );
|
||||
if( h )
|
||||
sb_printf( out, L"%s", h );
|
||||
sb_printf( out, L"%ls", h );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3253,7 +3253,7 @@ int parser_test( const wchar_t * buff,
|
|||
err = 1;
|
||||
if( out )
|
||||
{
|
||||
char *h;
|
||||
wchar_t *h;
|
||||
|
||||
error( SYNTAX_ERROR,
|
||||
tok_get_pos( &tok ),
|
||||
|
@ -3261,7 +3261,7 @@ int parser_test( const wchar_t * buff,
|
|||
print_errors( out, prefix );
|
||||
h = builtin_help_get( L"end" );
|
||||
if( h )
|
||||
sb_printf( out, L"%s", h );
|
||||
sb_printf( out, L"%ls", h );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3532,7 +3532,7 @@ int parser_test( const wchar_t * buff,
|
|||
|
||||
if( out && count>0 )
|
||||
{
|
||||
const char *h;
|
||||
const wchar_t *h;
|
||||
const wchar_t *cmd;
|
||||
|
||||
error( SYNTAX_ERROR,
|
||||
|
@ -3547,7 +3547,7 @@ int parser_test( const wchar_t * buff,
|
|||
h = builtin_help_get( cmd );
|
||||
if( cmd )
|
||||
{
|
||||
sb_printf( out, L"%s", h );
|
||||
sb_printf( out, L"%ls", h );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
22
print_help.c
Normal file
22
print_help.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
/** \file print_help.c
|
||||
Print help message for the specified command
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "print_help.h"
|
||||
|
||||
#define CMD_LEN 1024
|
||||
|
||||
void print_help( char *c, int fd )
|
||||
{
|
||||
char cmd[ CMD_LEN];
|
||||
int printed = snprintf( cmd, CMD_LEN, "fish -c '__fish_print_help %s >&%d'", c, fd );
|
||||
|
||||
if( printed < CMD_LEN )
|
||||
system( cmd );
|
||||
|
||||
}
|
15
print_help.h
Normal file
15
print_help.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
/** \file print_help.h
|
||||
Print help message for the specified command
|
||||
*/
|
||||
|
||||
#ifndef FISH_PRINT_HELP_H
|
||||
#define FISH_PRINT_HELP_H
|
||||
|
||||
/**
|
||||
Print help message for the specified command
|
||||
*/
|
||||
|
||||
void print_help( char *cmd, int fd );
|
||||
|
||||
#endif
|
|
@ -37,6 +37,7 @@
|
|||
#endif
|
||||
|
||||
#include "fallback.h"
|
||||
#include "print_help.h"
|
||||
|
||||
/*
|
||||
Small utility for setting the color.
|
||||
|
@ -90,8 +91,6 @@ int col_idx[]=
|
|||
}
|
||||
;
|
||||
|
||||
void print_help();
|
||||
|
||||
int translate_color( char *str )
|
||||
{
|
||||
char *endptr;
|
||||
|
@ -206,7 +205,7 @@ int main( int argc, char **argv )
|
|||
bgcolor = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
print_help();
|
||||
print_help( argv[0], 1 );
|
||||
exit(0);
|
||||
|
||||
case 'o':
|
||||
|
@ -254,7 +253,7 @@ int main( int argc, char **argv )
|
|||
{
|
||||
check_locale_init();
|
||||
fprintf( stderr, _("%s: Expected an argument\n"), SET_COLOR );
|
||||
print_help();
|
||||
print_help( argv[0], 2 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@ if set -q XDG_CONFIG_HOME
|
|||
set configdir $XDG_CONFIG_HOME
|
||||
end
|
||||
|
||||
|
||||
if not set -q __fish_datadir
|
||||
set -U __fish_datadir @datadir@/fish
|
||||
end
|
||||
|
||||
if not set -q fish_function_path
|
||||
set -U fish_function_path $configdir/fish/functions @sysconfdir@/fish/functions @datadir@/fish/functions
|
||||
|
|
7
share/functions/__fish_print_help.fish
Normal file
7
share/functions/__fish_print_help.fish
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
function __fish_print_help
|
||||
set -l help (nroff -man $__fish_datadir/man/$argv.1)
|
||||
set -l lines (count $help)
|
||||
echo
|
||||
printf "%s\n" $help| tail -n (expr $lines - 5 ) | head -n (expr $lines - 8)
|
||||
end
|
|
@ -1,5 +1,14 @@
|
|||
|
||||
function alias -d (_ "Legacy function for creating shellscript functions using an alias-like syntax")
|
||||
|
||||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help alias
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
set -l name
|
||||
set -l body
|
||||
switch (count $argv)
|
||||
|
|
|
@ -3,7 +3,7 @@ function contains -d (N_ "Test if a key is contained in a set of values")
|
|||
while count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case '-h' '--h' '--he' '--hel' '--help'
|
||||
help contains
|
||||
__fish_print_help contains
|
||||
return
|
||||
|
||||
case '--'
|
||||
|
@ -12,8 +12,8 @@ function contains -d (N_ "Test if a key is contained in a set of values")
|
|||
break
|
||||
|
||||
case '-*'
|
||||
printf (_ "%s: Unknown option '%s'\n") contains $argv[$i]
|
||||
help contains
|
||||
printf (_ "%s: Unknown option '%s'\n") contains $argv[1]
|
||||
__fish_print_help contains >&2
|
||||
return 1
|
||||
|
||||
case '*'
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
|
||||
function dirh -d (N_ "Print the current directory history (the back- and fwd- lists)")
|
||||
|
||||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help dirh
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
# Avoid set comment
|
||||
set -l current (command pwd)
|
||||
set -l separator " "
|
||||
|
|
|
@ -22,7 +22,8 @@ function help -d (N_ "Show help for the fish shell")
|
|||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
set argv help
|
||||
__fish_print_help help
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ function isatty -d "Tests if a file descriptor is a tty"
|
|||
switch $argv[1]
|
||||
|
||||
case -h --h --he --hel --help
|
||||
help isatty
|
||||
__fish_print_help isatty
|
||||
return 0
|
||||
|
||||
case stdin
|
||||
set fd 0
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
|
||||
function math -d (N_ "Perform math calculations in bc")
|
||||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help math
|
||||
return 0
|
||||
end
|
||||
|
||||
set -l out (echo $argv|bc)
|
||||
echo $out
|
||||
switch $out
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
|
||||
function nextd -d (N_ "Move forward in the directory history")
|
||||
|
||||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help nextd
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
# Parse arguments
|
||||
set -l show_hist 0
|
||||
set -l times 1
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
|
||||
if not test (uname) = Darwin
|
||||
function open -d (N_ "Open file in default application")
|
||||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help dirh
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
if type -f xdg-open >/dev/null
|
||||
xdg-open $argv
|
||||
else
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
|
||||
function popd -d (N_ "Pop dir from stack")
|
||||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help popd
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
if test $dirstack[1]
|
||||
cd $dirstack[1]
|
||||
else
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
|
||||
function prevd -d (N_ "Move back in the directory history")
|
||||
|
||||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help prevd
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
# Parse arguments
|
||||
set -l show_hist 0
|
||||
set -l times 1
|
||||
|
|
|
@ -8,8 +8,7 @@ function psub -d (N_ "Read from stdin into a file and output the filename. Remov
|
|||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case '-h*' --h --he --hel --help
|
||||
|
||||
help psub
|
||||
__fish_print_help psub
|
||||
return 0
|
||||
|
||||
case '*'
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
|
||||
|
||||
function pushd -d (N_ "Push directory to stack")
|
||||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help pushd
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
# Comment to avoid set completions
|
||||
set -g dirstack (command pwd) $dirstack
|
||||
cd $argv[1]
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
|
||||
function save_function -d (N_ "Save the current definition of all specified functions to file")
|
||||
|
||||
if count $argv >/dev/null
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help save_function
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
set -l res 0
|
||||
|
||||
set -l configdir ~/.config
|
||||
|
|
|
@ -45,7 +45,7 @@ function trap -d 'Perform an action when the shell recives a signal'
|
|||
while count $opt >/dev/null
|
||||
switch $opt[1]
|
||||
case -h --help
|
||||
help trap
|
||||
__fish_print_help trap
|
||||
return 0
|
||||
|
||||
case -p --print
|
||||
|
|
|
@ -43,7 +43,7 @@ function type -d (N_ "Print the type of a command")
|
|||
set selection files
|
||||
|
||||
case -h --help
|
||||
help type
|
||||
__fish_print_help type
|
||||
return 0
|
||||
|
||||
case --
|
||||
|
|
|
@ -155,7 +155,7 @@ function umask -d (N_ "Set default file permission mask")
|
|||
|
||||
switch $opt[1]
|
||||
case -h --help
|
||||
help umask
|
||||
__fish_print_help umask
|
||||
return 0
|
||||
|
||||
case -p --as-command
|
||||
|
|
|
@ -9,10 +9,12 @@ function vared -d (N_ "Edit variable value")
|
|||
switch $argv
|
||||
|
||||
case '-h' '--h' '--he' '--hel' '--help'
|
||||
help vared
|
||||
__fish_print_help vared
|
||||
return 0
|
||||
|
||||
case '-*'
|
||||
printf (_ "%s: Unknown option %s\n") vared $argv
|
||||
return 1
|
||||
|
||||
case '*'
|
||||
if test (count $$argv ) -lt 2
|
||||
|
|
Loading…
Reference in a new issue