Merged changes from codemonkey and grissiom branches

Conflicts:
	kill.c
	seq.in
This commit is contained in:
Christopher Nilsson 2010-11-12 02:07:14 +11:00
commit 1b0ce33669
221 changed files with 6749 additions and 6514 deletions

4
.gitignore vendored
View file

@ -28,4 +28,6 @@ share/config.fish
share/man/ share/man/
toc.txt toc.txt
user_doc/ user_doc/
xsel-0.9.6/ xsel-1.2.0/
tests/*tmp.*
tests/foo.txt

View file

@ -60,7 +60,7 @@ optbindirs = @optbindirs@
# #
MACROS = -DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\" MACROS = -DLOCALEDIR=\"$(localedir)\" -DPREFIX=L\"$(prefix)\" -DDATADIR=L\"$(datadir)\" -DSYSCONFDIR=L\"$(sysconfdir)\"
CFLAGS = @CFLAGS@ $(MACROS) CFLAGS = @CFLAGS@ $(MACROS) $(EXTRA_CFLAGS)
CPPFLAGS = @CPPFLAGS@ CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LIBS@ @LDFLAGS@ LDFLAGS = @LIBS@ @LDFLAGS@
LDFLAGS_FISH = ${LDFLAGS} @LIBS_FISH@ @LDFLAGS_FISH@ LDFLAGS_FISH = ${LDFLAGS} @LIBS_FISH@ @LDFLAGS_FISH@
@ -245,7 +245,7 @@ FUNCTIONS_DIR_FILES := $(wildcard share/functions/*.fish)
# #
SIMPLE_PROGRAMS := fish set_color mimedb fish_pager fishd fish_indent SIMPLE_PROGRAMS := fish set_color mimedb fish_pager fishd fish_indent
PROGRAMS := $(SIMPLE_PROGRAMS) @XSEL@ @SEQ_FALLBACK@ PROGRAMS := $(SIMPLE_PROGRAMS) @XSEL_BIN@ @SEQ_FALLBACK@
# #
@ -264,6 +264,13 @@ TRANSLATIONS_SRC := $(wildcard po/*.po)
TRANSLATIONS := $(TRANSLATIONS_SRC:.po=.gmo) TRANSLATIONS := $(TRANSLATIONS_SRC:.po=.gmo)
#
# Extra util
#
XSEL := @XSEL@
XSEL_BIN := @XSEL_BIN@
# #
# Make everything needed for installing fish # Make everything needed for installing fish
# #
@ -292,9 +299,12 @@ Makefile: Makefile.in configure
# #
debug: debug:
$(MAKE) fish CFLAGS="@CFLAGS@ $(MACROS) -O0 -Wno-unused -Werror -g" $(MAKE) all EXTRA_CFLAGS="-O0 -Wno-unused -Werror -g"
.PHONY: debug .PHONY: debug
prof:
$(MAKE) all EXTRA_CFLAGS="-pg" LDFLAGS="-pg"
.PHONY: prof
# #
# User documentation, describing the features of the fish shell. # User documentation, describing the features of the fish shell.
@ -342,11 +352,8 @@ test: $(PROGRAMS) fish_tests
# Build the xsel program, which is maintained in its own tarball # Build the xsel program, which is maintained in its own tarball
# #
xsel-0.9.6: $(XSEL_BIN):
tar -xf xsel-0.9.6.tar $(MAKE) -C $(XSEL) || echo "Failed to build xsel - either add the required dependencies or use './configure --without-xsel' to disable it."
xsel-0.9.6/xsel: xsel-0.9.6
cd xsel-0.9.6; ./configure && make || echo "Failed to build xsel - either add the required dependencies or use './configure --without-xsel' to disable it."
# #
@ -857,6 +864,7 @@ distclean: clean
rm -f fish.spec Doxyfile.help rm -f fish.spec Doxyfile.help
rm -f etc/config.fish seq share/config.fish rm -f etc/config.fish seq share/config.fish
rm -f config.status config.log config.h Makefile rm -f config.status config.log config.h Makefile
rm -rf $(XSEL)
.PHONY: distclean .PHONY: distclean
@ -875,8 +883,8 @@ clean:
rm -f fish-@PACKAGE_VERSION@.tar.bz2 rm -f fish-@PACKAGE_VERSION@.tar.bz2
rm -rf doc; rm -rf doc;
rm -rf fish-@PACKAGE_VERSION@ rm -rf fish-@PACKAGE_VERSION@
rm -rf xsel-0.9.6/
rm -f $(TRANSLATIONS) rm -f $(TRANSLATIONS)
-make -C $(XSEL) clean
.PHONY: clean .PHONY: clean

100
builtin.c
View file

@ -602,7 +602,7 @@ static int builtin_bind( wchar_t **argv )
woptind=0; woptind=0;
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {
@ -773,7 +773,7 @@ static int builtin_block( wchar_t **argv )
woptind=0; woptind=0;
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {
@ -925,7 +925,7 @@ static int builtin_builtin( wchar_t **argv )
woptind=0; woptind=0;
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {
@ -1015,7 +1015,7 @@ static int builtin_emit( wchar_t **argv )
woptind=0; woptind=0;
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {
@ -1086,7 +1086,7 @@ static int builtin_generic( wchar_t **argv )
int argc=builtin_count_args( argv ); int argc=builtin_count_args( argv );
woptind=0; woptind=0;
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {
@ -1252,10 +1252,11 @@ static int builtin_functions( wchar_t **argv )
int show_hidden=0; int show_hidden=0;
int res = STATUS_BUILTIN_OK; int res = STATUS_BUILTIN_OK;
int query = 0; int query = 0;
int copy = 0;
woptind=0; woptind=0;
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {
@ -1282,6 +1283,10 @@ static int builtin_functions( wchar_t **argv )
L"query", no_argument, 0, 'q' L"query", no_argument, 0, 'q'
} }
, ,
{
L"copy", no_argument, 0, 'c'
}
,
{ {
0, 0, 0, 0 0, 0, 0, 0
} }
@ -1294,7 +1299,7 @@ static int builtin_functions( wchar_t **argv )
int opt = wgetopt_long( argc, int opt = wgetopt_long( argc,
argv, argv,
L"ed:nahq", L"ed:nahqc",
long_options, long_options,
&opt_index ); &opt_index );
if( opt == -1 ) if( opt == -1 )
@ -1305,10 +1310,10 @@ static int builtin_functions( wchar_t **argv )
case 0: case 0:
if(long_options[opt_index].flag != 0) if(long_options[opt_index].flag != 0)
break; break;
sb_printf( sb_err, sb_printf( sb_err,
BUILTIN_ERR_UNKNOWN, BUILTIN_ERR_UNKNOWN,
argv[0], argv[0],
long_options[opt_index].name ); long_options[opt_index].name );
builtin_print_help( argv[0], sb_err ); builtin_print_help( argv[0], sb_err );
@ -1338,6 +1343,10 @@ static int builtin_functions( wchar_t **argv )
query = 1; query = 1;
break; break;
case 'c':
copy = 1;
break;
case '?': case '?':
builtin_unknown_option( argv[0], argv[woptind-1] ); builtin_unknown_option( argv[0], argv[woptind-1] );
return STATUS_BUILTIN_ERROR; return STATUS_BUILTIN_ERROR;
@ -1347,9 +1356,9 @@ static int builtin_functions( wchar_t **argv )
} }
/* /*
Erase, desc, query and list are mutually exclusive Erase, desc, query, copy and list are mutually exclusive
*/ */
if( (erase + (!!desc) + list + query) > 1 ) if( (erase + (!!desc) + list + query + copy) > 1 )
{ {
sb_printf( sb_err, sb_printf( sb_err,
_( L"%ls: Invalid combination of options\n" ), _( L"%ls: Invalid combination of options\n" ),
@ -1434,6 +1443,61 @@ static int builtin_functions( wchar_t **argv )
al_destroy( &names ); al_destroy( &names );
return STATUS_BUILTIN_OK; return STATUS_BUILTIN_OK;
} }
else if( copy )
{
wchar_t *current_func;
wchar_t *new_func;
if( argc-woptind != 2 )
{
sb_printf( sb_err,
_( L"%ls: Expected exactly two names (current function name, and new function name)\n" ),
argv[0] );
builtin_print_help ( argv[0], sb_err );
return STATUS_BUILTIN_ERROR;
}
current_func = argv[woptind];
new_func = argv[woptind+1];
if( !function_exists( current_func ) )
{
sb_printf( sb_err,
_( L"%ls: Function '%ls' does not exist\n" ),
argv[0],
current_func );
builtin_print_help( argv[0], sb_err );
return STATUS_BUILTIN_ERROR;
}
if( (wcsfuncname( new_func ) != 0) || parser_keywords_is_reserved( new_func ) )
{
sb_printf( sb_err,
_( L"%ls: Illegal function name '%ls'\n"),
argv[0],
new_func );
builtin_print_help( argv[0], sb_err );
return STATUS_BUILTIN_ERROR;
}
// keep things simple: don't allow existing names to be copy targets.
if( function_exists( new_func ) )
{
sb_printf( sb_err,
_( L"%ls: Function '%ls' already exists. Cannot create copy '%ls'\n" ),
argv[0],
new_func,
current_func );
builtin_print_help( argv[0], sb_err );
return STATUS_BUILTIN_ERROR;
}
if( function_copy( current_func, new_func ) )
return STATUS_BUILTIN_OK;
return STATUS_BUILTIN_ERROR;
}
for( i=woptind; i<argc; i++ ) for( i=woptind; i<argc; i++ )
{ {
@ -1476,7 +1540,7 @@ static int builtin_function( wchar_t **argv )
parser_push_block( FUNCTION_DEF ); parser_push_block( FUNCTION_DEF );
events=al_halloc( current_block ); events=al_halloc( current_block );
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {
@ -1847,7 +1911,7 @@ static int builtin_random( wchar_t **argv )
woptind=0; woptind=0;
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {
@ -1970,7 +2034,7 @@ static int builtin_read( wchar_t **argv )
while( 1 ) while( 1 )
{ {
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {
@ -3434,7 +3498,7 @@ static int builtin_breakpoint( wchar_t **argv )
{ {
parser_push_block( BREAKPOINT ); parser_push_block( BREAKPOINT );
reader_read( 0, real_io ); reader_read( STDIN_FILENO, real_io );
parser_pop_block(); parser_pop_block();
@ -3595,7 +3659,7 @@ static int builtin_case( wchar_t **argv )
/** /**
Data about all the builtin commands in fish Data about all the builtin commands in fish
*/ */
const static builtin_data_t builtin_data[]= static const builtin_data_t builtin_data[]=
{ {
{ {
L"block", &builtin_block, N_( L"Temporarily block delivery of events" ) L"block", &builtin_block, N_( L"Temporarily block delivery of events" )

View file

@ -267,7 +267,7 @@ static int builtin_commandline( wchar_t **argv )
while( 1 ) while( 1 )
{ {
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {

View file

@ -28,7 +28,7 @@ Functions used for implementing the complete builtin.
/** /**
Internal storage for the builtin_get_temporary_buffer() function. Internal storage for the builtin_get_temporary_buffer() function.
*/ */
const static wchar_t *temporary_buffer; static const wchar_t *temporary_buffer;
/* /*
builtin_complete_* are a set of rather silly looping functions that builtin_complete_* are a set of rather silly looping functions that
@ -320,7 +320,7 @@ static int builtin_complete( wchar_t **argv )
while( res == 0 ) while( res == 0 )
{ {
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {

View file

@ -173,7 +173,7 @@ static int builtin_jobs( wchar_t **argv )
while( 1 ) while( 1 )
{ {
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {

View file

@ -417,7 +417,7 @@ static int builtin_set( wchar_t **argv )
/** /**
Variables used for parsing the argument list Variables used for parsing the argument list
*/ */
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {

View file

@ -49,7 +49,7 @@ struct resource_t
/** /**
Array of resource_t structs, describing all known resource types. Array of resource_t structs, describing all known resource types.
*/ */
const static struct resource_t resource_arr[] = static const struct resource_t resource_arr[] =
{ {
{ {
RLIMIT_CORE, L"Maximum size of core files created", L'c', 1024 RLIMIT_CORE, L"Maximum size of core files created", L'c', 1024
@ -266,7 +266,7 @@ static int builtin_ulimit( wchar_t ** argv )
while( 1 ) while( 1 )
{ {
const static struct woption static const struct woption
long_options[] = long_options[] =
{ {
{ {

View file

@ -11,6 +11,11 @@
AC_INIT(fish,1.23.1,fish-users@lists.sf.net) AC_INIT(fish,1.23.1,fish-users@lists.sf.net)
#
# preserve configure arguments for xsel
#
conf_arg=$@
# #
# List of output variables produced by this configure script # List of output variables produced by this configure script
@ -31,6 +36,7 @@ AC_SUBST(prefix)
AC_SUBST(SEQ_FALLBACK) AC_SUBST(SEQ_FALLBACK)
AC_SUBST(XSEL) AC_SUBST(XSEL)
AC_SUBST(XSEL_MAN) AC_SUBST(XSEL_MAN)
AC_SUBST(XSEL_BIN)
AC_SUBST(XSEL_MAN_PATH) AC_SUBST(XSEL_MAN_PATH)
# #
@ -199,16 +205,18 @@ AC_ARG_WITH(
xsel, xsel,
AC_HELP_STRING( AC_HELP_STRING(
[--without-xsel], [--without-xsel],
[do not build the xsel program needed for X clipboard integration] [do not build the xsel program needed for X clipboard integration.
If build xsel, it will be configured with the same options as fish.]
), ),
[xsel=$withval], [xsel=$withval],
[xsel=with_xsel] [xsel=with_xsel]
) )
if [[ "$xsel" = "with_xsel" ]]; then if [[ "$xsel" = "with_xsel" ]]; then
XSEL=xsel-0.9.6/xsel XSEL=xsel-1.2.0
XSEL_BIN=$XSEL/xsel
XSEL_MAN=xsel.1x XSEL_MAN=xsel.1x
XSEL_MAN_PATH=xsel-0.9.6/xsel.1x XSEL_MAN_PATH=$XSEL/xsel.1x
fi fi
@ -975,6 +983,12 @@ if test ! x$local_found_posix_switch = xyes; then
echo "Some fish features may be disabled." echo "Some fish features may be disabled."
fi fi
if [[ "$xsel" = "with_xsel" ]]; then
echo "Now configure xsel with $conf_arg"
rm -rf $XSEL
tar xf $XSEL.tar.gz
cd $XSEL && ./configure $conf_arg
fi
echo "fish is now configured." echo "fish is now configured."
echo "Use 'make' and 'make install' to build and install fish." echo "Use 'make' and 'make install' to build and install fish."

View file

@ -8,6 +8,7 @@
This builtin command is used to print or erase functions. This builtin command is used to print or erase functions.
- <code>-a</code> or <code>--all</code> list all functions, even those whose name start with an underscore. - <code>-a</code> or <code>--all</code> list all functions, even those whose name start with an underscore.
- <code>-c OLDNAME NEWNAME</code> or <code>--copy OLDNAME NEWNAME</code> creates a new function named NEWNAME, using the definition of the OLDNAME function.
- <code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> change the description of this function - <code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> change the description of this function
- <code>-e</code> or <code>--erase</code> causes the specified functions to be erased. - <code>-e</code> or <code>--erase</code> causes the specified functions to be erased.
- <code>-h</code> or <code>--help</code> display a help message and exit - <code>-h</code> or <code>--help</code> display a help message and exit
@ -23,5 +24,8 @@ Automatically loaded functions can not be removed using functions
-e. Either remove the definition file or change the -e. Either remove the definition file or change the
$fish_function_path variable to remove autoloaded functions. $fish_function_path variable to remove autoloaded functions.
Function copies, created with -c, will not have any event/signal/on-exit
notifications that the original may have had.
The exit status of the functions builtin is the number functions The exit status of the functions builtin is the number functions
specified in the argument list that do not exist. specified in the argument list that do not exist.

34
env.c
View file

@ -527,6 +527,7 @@ void env_init()
struct passwd *pw; struct passwd *pw;
wchar_t *uname; wchar_t *uname;
wchar_t *version; wchar_t *version;
wchar_t *shlvl;
sb_init( &dyn_var ); sb_init( &dyn_var );
b_init( &export_buffer ); b_init( &export_buffer );
@ -543,6 +544,7 @@ void env_init()
hash_put( &env_read_only, L"LINES", L"" ); hash_put( &env_read_only, L"LINES", L"" );
hash_put( &env_read_only, L"COLUMNS", L"" ); hash_put( &env_read_only, L"COLUMNS", L"" );
hash_put( &env_read_only, L"PWD", L"" ); hash_put( &env_read_only, L"PWD", L"" );
hash_put( &env_read_only, L"SHLVL", L"" );
/* /*
Names of all dynamically calculated variables Names of all dynamically calculated variables
@ -644,6 +646,38 @@ void env_init()
&start_fishd, &start_fishd,
&universal_callback ); &universal_callback );
/*
Set up SHLVL variable
*/
shlvl = env_get( L"SHLVL" );
if ( shlvl )
{
wchar_t *nshlvl, **end_nshlvl;
/* add an extra space for digit dump (9+1=10) */
size_t i = wcslen( shlvl ) + 2 * sizeof(wchar_t);
nshlvl = malloc(i);
end_nshlvl = calloc( 1, sizeof(nshlvl) );
if ( !nshlvl || !end_nshlvl )
DIE_MEM();
if ( nshlvl && swprintf( nshlvl, i,
L"%ld", wcstoul( shlvl, end_nshlvl, 10 )+1 ) != -1 )
{
env_set( L"SHLVL",
nshlvl,
ENV_GLOBAL | ENV_EXPORT );
}
free( end_nshlvl );
free( nshlvl );
}
else
{
env_set( L"SHLVL",
L"1",
ENV_GLOBAL | ENV_EXPORT );
}
/* /*
Set correct defaults for e.g. USER and HOME variables Set correct defaults for e.g. USER and HOME variables
*/ */

8
fish.c
View file

@ -323,12 +323,12 @@ int main( int argc, char **argv )
{ {
if( my_optind == argc ) if( my_optind == argc )
{ {
res = reader_read( 0, 0 ); res = reader_read( STDIN_FILENO, 0 );
} }
else else
{ {
char **ptr; char **ptr;
char *file = *(argv+1); char *file = *(argv+(my_optind++));
int i; int i;
string_buffer_t sb; string_buffer_t sb;
int fd; int fd;
@ -340,11 +340,11 @@ int main( int argc, char **argv )
return 1; return 1;
} }
if( *(argv+2)) if( *(argv+my_optind))
{ {
sb_init( &sb ); sb_init( &sb );
for( i=1,ptr = argv+2; *ptr; i++, ptr++ ) for( i=1,ptr = argv+my_optind; *ptr; i++, ptr++ )
{ {
if( i != 1 ) if( i != 1 )
sb_append( &sb, ARRAY_SEP_STR ); sb_append( &sb, ARRAY_SEP_STR );

View file

@ -218,6 +218,43 @@ void function_add( function_data_t *data )
} }
int function_copy( const wchar_t *name, const wchar_t *new_name )
{
int i;
function_internal_data_t *d, *orig_d;
CHECK( name, 0 );
CHECK( new_name, 0 );
orig_d = (function_internal_data_t *)hash_get(&function, name);
if( !orig_d )
return 0;
d = halloc(0, sizeof( function_internal_data_t ) );
d->definition_offset = orig_d->definition_offset;
d->definition = halloc_wcsdup( d, orig_d->definition );
if( orig_d->named_arguments )
{
d->named_arguments = al_halloc( d );
for( i=0; i<al_get_count( orig_d->named_arguments ); i++ )
{
al_push( d->named_arguments, halloc_wcsdup( d, (wchar_t *)al_get( orig_d->named_arguments, i ) ) );
}
d->description = orig_d->description?halloc_wcsdup(d, orig_d->description):0;
d->shadows = orig_d->shadows;
// This new instance of the function shouldn't be tied to the def
// file of the original.
d->definition_file = 0;
d->is_autoload = 0;
}
hash_put( &function, intern(new_name), d );
return 1;
}
int function_exists( const wchar_t *cmd ) int function_exists( const wchar_t *cmd )
{ {

View file

@ -131,4 +131,10 @@ array_list_t *function_get_named_arguments( const wchar_t *name );
*/ */
int function_get_shadows( const wchar_t *name ); int function_get_shadows( const wchar_t *name );
/**
Creates a new function using the same definition as the specified function.
Returns non-zero if copy is successful.
*/
int function_copy( const wchar_t *name, const wchar_t *new_name );
#endif #endif

View file

@ -293,7 +293,7 @@ static int interrupt_handler()
/* /*
Fire any pending events Fire any pending events
*/ */
event_fire( 0 ); event_fire( NULL );
/* /*
Reap stray processes, including printing exit status messages Reap stray processes, including printing exit status messages

88
kill.c
View file

@ -50,16 +50,16 @@ static wchar_t *cut_buffer=0;
*/ */
static int has_xsel() static int has_xsel()
{ {
static int called=0; static int called=0;
static int res = 0; static int res = 0;
if (!called) { if (!called) {
void *context = halloc(0, 0); void *context = halloc(0, 0);
wchar_t *path = path_get_path( context, L"xsel" ); wchar_t *path = path_get_path( context, L"xsel" );
res = !!path; res = !!path;
halloc_free( context ); halloc_free( context );
called = 1; called = 1;
} }
return res; return res;
} }
@ -93,51 +93,51 @@ static void kill_add_internal( wchar_t *str )
void kill_add( wchar_t *str ) void kill_add( wchar_t *str )
{ {
wchar_t *cmd = NULL; wchar_t *cmd = NULL;
wchar_t *escaped_str; wchar_t *escaped_str;
kill_add_internal(str); kill_add_internal(str);
/* /*
Check to see if user has set the FISH_CLIPBOARD_CMD variable, Check to see if user has set the FISH_CLIPBOARD_CMD variable,
and, if so, use it instead of checking the display, etc. and, if so, use it instead of checking the display, etc.
I couldn't think of a safe way to allow overide of the echo I couldn't think of a safe way to allow overide of the echo
command too, so, the command used must accept the input via stdin. command too, so, the command used must accept the input via stdin.
*/ */
wchar_t *clipboard; wchar_t *clipboard;
if( (clipboard = env_get(L"FISH_CLIPBOARD_CMD")) ) if( (clipboard = env_get(L"FISH_CLIPBOARD_CMD")) )
{ {
escaped_str = escape( str, 1 ); escaped_str = escape( str, 1 );
cmd = wcsdupcat(L"echo -n ", escaped_str, clipboard); cmd = wcsdupcat(L"echo -n ", escaped_str, clipboard);
} }
else else
{ {
/* This is for sending the kill to the X copy-and-paste buffer */ /* This is for sending the kill to the X copy-and-paste buffer */
if( !has_xsel() ) { if( !has_xsel() ) {
return; return;
} }
wchar_t *disp; wchar_t *disp;
if( (disp = env_get( L"DISPLAY" )) ) if( (disp = env_get( L"DISPLAY" )) )
{ {
escaped_str = escape( str, 1 ); escaped_str = escape( str, 1 );
cmd = wcsdupcat(L"echo ", escaped_str, L"|xsel -b" ); cmd = wcsdupcat(L"echo ", escaped_str, L"|xsel -b" );
} }
} }
if (cmd != NULL) if (cmd != NULL)
{ {
if( exec_subshell( cmd, 0 ) == -1 ) if( exec_subshell( cmd, 0 ) == -1 )
{ {
/* /*
Do nothing on failiure Do nothing on failiure
*/ */
} }
free( cut_buffer ); free( cut_buffer );
free( cmd ); free( cmd );
cut_buffer = escaped_str; cut_buffer = escaped_str;
} }
} }

View file

@ -292,7 +292,7 @@ struct block_lookup_entry
/** /**
List of all legal block types List of all legal block types
*/ */
const static struct block_lookup_entry block_lookup[]= static const struct block_lookup_entry block_lookup[]=
{ {
{ {
WHILE, L"while", WHILE_BLOCK WHILE, L"while", WHILE_BLOCK
@ -1514,7 +1514,9 @@ static void parse_job_argument_list( process_t *p,
{ {
case TOK_STRING: case TOK_STRING:
{ {
target = (wchar_t *)expand_one( j, wcsdup( tok_last( tok ) ), 0); target = (wchar_t *)expand_one( j,
wcsdup( tok_last( tok ) ),
no_exec ? EXPAND_SKIP_VARIABLES : 0);
if( target == 0 && error_code == 0 ) if( target == 0 && error_code == 0 )
{ {
@ -2538,7 +2540,7 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type )
error_code = 0; error_code = 0;
event_fire( 0 ); event_fire( NULL );
while( tok_has_next( current_tokenizer ) && while( tok_has_next( current_tokenizer ) &&
!error_code && !error_code &&
@ -2546,7 +2548,7 @@ int eval( const wchar_t *cmd, io_data_t *io, int block_type )
!exit_status() ) !exit_status() )
{ {
eval_job( current_tokenizer ); eval_job( current_tokenizer );
event_fire( 0 ); event_fire( NULL );
} }
int prev_block_type = current_block->type; int prev_block_type = current_block->type;

View file

@ -624,10 +624,16 @@ void reader_write_title()
don't. Since we can't see the underlying terminal below screen don't. Since we can't see the underlying terminal below screen
there is no way to fix this. there is no way to fix this.
*/ */
if( !term || !contains( term, L"xterm", L"screen", L"nxterm", L"rxvt" ) ) if ( !term )
{
return;
}
if( !contains( term, L"xterm", L"screen", L"nxterm", L"rxvt" ) )
{ {
char *n = ttyname( STDIN_FILENO ); char *n = ttyname( STDIN_FILENO );
if( contains( term, L"linux" ) ) if( contains( term, L"linux" ) )
{ {
return; return;
@ -641,7 +647,7 @@ void reader_write_title()
title = function_exists( L"fish_title" )?L"fish_title":DEFAULT_TITLE; title = function_exists( L"fish_title" )?L"fish_title":DEFAULT_TITLE;
if( wcslen( title ) ==0 ) if( wcslen( title ) == 0 )
return; return;
al_init( &l ); al_init( &l );
@ -695,14 +701,11 @@ static void exec_prompt()
sb_clear( &data->prompt_buff ); sb_clear( &data->prompt_buff );
for( i=0; i<al_get_count( &prompt_list); i++ ) for( i = 0; i < al_get_count( &prompt_list )-1; i++ )
{ {
sb_append( &data->prompt_buff, (wchar_t *)al_get( &prompt_list, i ) ); sb_append( &data->prompt_buff, (wchar_t *)al_get( &prompt_list, i ), L"\n" );
if (i + 1 < al_get_count( &prompt_list))
{
sb_append( &data->prompt_buff, L"\n" );
}
} }
sb_append( &data->prompt_buff, (wchar_t *)al_get( &prompt_list, i ));
al_foreach( &prompt_list, &free ); al_foreach( &prompt_list, &free );
al_destroy( &prompt_list ); al_destroy( &prompt_list );

View file

@ -236,6 +236,10 @@ static int calc_prompt_width( wchar_t *prompt )
{ {
res = next_tab_stop( res ); res = next_tab_stop( res );
} }
else if( prompt[j] == L'\n' )
{
res = 0;
}
else else
{ {
/* /*

4
seq.in
View file

@ -46,7 +46,7 @@ for i in $from $step $to
end end
if [ $step -ge 0 ] if [ $step -ge 0 ]
echo "for( i=$from; i<=$to ; i+=$step ) i;" | bc echo "for( i=$from; i<=$to ; i+=$step ) i;" | bc
else else
echo "for( i=$from; i>=$to ; i+=$step ) i;" | bc echo "for( i=$from; i>=$to ; i+=$step ) i;" | bc
end end

View file

@ -90,9 +90,9 @@ complete -c git -n '__fish_git_needs_command' -a add -d 'Add file contents to
### checkout ### checkout
complete -f -c git -n '__fish_git_needs_command' -a checkout -d 'Checkout and switch to a branch' complete -f -c git -n '__fish_git_needs_command' -a checkout -d 'Checkout and switch to a branch'
complete -c git -n '__fish_git_using_command checkout' -a '(__fish_git_branches)' --description 'Branch' complete -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_branches)' --description 'Branch'
complete -c git -n '__fish_git_using_command checkout' -a '(__fish_git_tags)' --description 'Tag' complete -f -c git -n '__fish_git_using_command checkout' -a '(__fish_git_tags)' --description 'Tag'
complete -c git -n '__fish_git_using_command checkout' -s b -d 'Create a new branch' complete -f -c git -n '__fish_git_using_command checkout' -s b -d 'Create a new branch'
# TODO options # TODO options
### apply ### apply
@ -222,5 +222,12 @@ complete -f -c git -n '__fish_git_needs_command' -a config -d 'Set and read git
complete -f -c git -n '__fish_git_needs_command' -a format-patch -d 'Generate patch series to send upstream' complete -f -c git -n '__fish_git_needs_command' -a format-patch -d 'Generate patch series to send upstream'
complete -f -c git -n '__fish_git_using_command format-patch' -a '(__fish_git_branches)' -d 'Branch' complete -f -c git -n '__fish_git_using_command format-patch' -a '(__fish_git_branches)' -d 'Branch'
### aliases (custom user-definer commands) ## git submodule
complete -f -c git -n '__fish_git_needs_command' -a submodule -d 'Initialize, update or inspect submodules'
complete -f -c git -n '__fish_git_using_command submodule' -a 'add status init update summary foreach sync' -d 'Make a GPG-signed tag'
## git whatchanged
complete -f -c git -n '__fish_git_needs_command' -a whatchanged -d 'Show logs with difference each commit introduces'
## Aliases (custom user-defined commands)
complete -c git -n '__fish_git_needs_command' -a '(git config --get-regexp alias | sed -e "s/^alias\.\(\S\+\).*/\1/")' -d 'Alias (user-defined command)' complete -c git -n '__fish_git_needs_command' -a '(git config --get-regexp alias | sed -e "s/^alias\.\(\S\+\).*/\1/")' -d 'Alias (user-defined command)'

View file

@ -31,7 +31,7 @@ function __fish_complete_cd -d "Completions for the cd command"
# in case the CDPATH directory is relative # in case the CDPATH directory is relative
builtin cd $wd builtin cd $wd
builtin cd $i eval builtin cd $i
eval printf '"%s\tDirectory in "'$i'"\n"' (commandline -ct)\*/ eval printf '"%s\tDirectory in "'$i'"\n"' (commandline -ct)\*/
end end

View file

@ -1,5 +1,5 @@
function sgrep -d "Call grep without honoring GREP_OPTIONS settings" function sgrep -d "Call grep without honoring GREP_OPTIONS settings"
set -l GREP_OPTIONS set -l GREP_OPTIONS
grep $argv command grep $argv
end end

View file

@ -60,7 +60,7 @@ static int block_count=0;
Lookup table used to convert between signal names and signal ids, Lookup table used to convert between signal names and signal ids,
etc. etc.
*/ */
const static struct lookup_entry lookup[] = static const struct lookup_entry lookup[] =
{ {
#ifdef SIGHUP #ifdef SIGHUP
{ {

View file

@ -4,6 +4,43 @@
# instad of using autotest to provide additional # instad of using autotest to provide additional
# testing for fish. :-) # testing for fish. :-)
if [ "$argv" != '-n' ]
# begin...end has bug in error redirecting...
begin
../fish -n ./test.fish ^top.tmp.err
../fish -n ./test.fish -n ^^top.tmp.err
../fish ./test.fish -n ^^top.tmp.err
end | tee top.tmp.out
echo $status >top.tmp.status
set res ok
if diff top.tmp.out top.out >/dev/null
else
set res fail
echo Output differs for file test.fish
end
if diff top.tmp.err top.err >/dev/null
else
set res fail
echo Error output differs for file test.fish
end
if test (cat top.tmp.status) = (cat top.status)
else
set res fail
echo Exit status differs for file test.fish
end
if test $res = ok;
echo File test.fish tested ok
else
echo File test.fish failed tests
end;
exit
end
echo Testing high level script functionality echo Testing high level script functionality
for i in *.in for i in *.in

6
tests/top.err Normal file
View file

@ -0,0 +1,6 @@
fish: Expected redirection specification, got token of type '$i'
/usr/local/src/grissioms-fish-shell/tests/test.fish (line 51): ../fish <$i >tmp.out ^tmp.err
^
fish: Expected redirection specification, got token of type '$i'
/usr/local/src/grissioms-fish-shell/tests/test.fish (line 51): ../fish <$i >tmp.out ^tmp.err
^

6
tests/top.out Normal file
View file

@ -0,0 +1,6 @@
Testing high level script functionality
File test1.in tested ok
File test2.in tested ok
File test3.in tested ok
File test4.in tested ok
File test5.in tested ok

1
tests/top.status Normal file
View file

@ -0,0 +1 @@
0

Binary file not shown.

BIN
xsel-1.2.0.tar.gz Normal file

Binary file not shown.