Compare commits

..

24 Commits

Author SHA1 Message Date
axel
e2ebc0e443 Set version to 1.17.0, disable fishd optimization patch.
darcs-hash:20051201154544-ac50b-9b0f5502659d9f1facc04e4fd6a0b7287b197f2d.gz
2005-12-02 01:45:44 +10:00
axel
8ff66e718c Fix broken recursive wildcard patch
darcs-hash:20051130153303-ac50b-3d0973badb50a98fe8038135a031a8ee14e4f894.gz
2005-12-01 01:33:03 +10:00
axel
2789da6a1a Only insert fishd barrier after non-builtin commands to increase performance
darcs-hash:20051129195132-ac50b-7fcf7b2458b162c9c668fe823f17dc070604b00d.gz
2005-11-30 05:51:32 +10:00
axel
51c345311a Make the not builtin work with shellscript functions
darcs-hash:20051129195030-ac50b-7ada30d327f2dcc8ad23f56b0a36c975cb90c481.gz
2005-11-30 05:50:30 +10:00
axel
4a68a34c50 Change stupid call signature for tilde expand function
darcs-hash:20051129165202-ac50b-f442d0d75864317cc70059fffe5e8eb956ad54a6.gz
2005-11-30 02:52:02 +10:00
axel
9993ff07f2 Fix problem with recursive wildcards not working properly when postfixed with a regular string
darcs-hash:20051129143352-ac50b-6fec789be36250f29d35458b15dbae423eed195c.gz
2005-11-30 00:33:52 +10:00
axel
fc8b56da0d Remove accidentally included test code for recursive wildcard feature
darcs-hash:20051129101414-ac50b-929f0b9928bbed8a485699c66e1b4e3e8cedcfdc.gz
2005-11-29 20:14:14 +10:00
axel
02981a1750 Minor cleanups
darcs-hash:20051129101303-ac50b-11843dc32a9d05037b907fe1ac5df6a90cb7dd36.gz
2005-11-29 20:13:03 +10:00
axel
c2e6b07b35 Try to report IO redirection errors resulting from redirection stderr
darcs-hash:20051129101206-ac50b-970569a8b710d74b6e16a3c09b8848618cec4a7e.gz
2005-11-29 20:12:06 +10:00
James Vega
8fcacdd5df common.c: Include the header file for ioctl()
darcs-hash:20051128144202-35ec8-5148e095c81538cb26c232e93dbe94a93e75e253.gz
2005-11-29 00:42:02 +10:00
axel
6bf58e44f4 Make sure fishd saves before exiting from signal
darcs-hash:20051127232409-ac50b-d316781e373c078fecf857a199594a00184361a9.gz
2005-11-28 09:24:09 +10:00
axel
bda7948719 Make sure fishd synchronization happens only when needed
darcs-hash:20051127232208-ac50b-927157fb9b5d3e44981f9ec029735531ae59fd61.gz
2005-11-28 09:22:08 +10:00
axel
e800fca499 Use better test for presense of getopt_long function
darcs-hash:20051127150603-ac50b-566999b0cb32bc150dc6ef43220452ab42f1ad64.gz
2005-11-28 01:06:03 +10:00
axel
eed4b75389 Remove config.h.in from repo, it is autogenerated by autoheader
darcs-hash:20051125162839-ac50b-bbd4dc02684028a45c19de50cdfa52e020368491.gz
2005-11-26 02:28:39 +10:00
axel
5974dd68b0 Use iswspace instead of the GNU extention iswblank
darcs-hash:20051125144434-ac50b-088a2a8066537f19f287f9dad1611a172addd053.gz
2005-11-26 00:44:34 +10:00
axel
680c0aff05 Use short style switch on set_color, since long style getopt not always available
darcs-hash:20051125144406-ac50b-ca222e2fb3f2396489fb5eca64f2eff32b654404.gz
2005-11-26 00:44:06 +10:00
axel
4a2bdeebef Fire pending events when interrupted while reading from keyboard
darcs-hash:20051125141826-ac50b-12e763c0a7f1b4e9136e38de7a8921ff2d1a74e7.gz
2005-11-26 00:18:26 +10:00
axel
dfa251a1ab Remove ifdefs from function code
darcs-hash:20051125141657-ac50b-4dabc1dea3c90accafdcab78f683412858d77541.gz
2005-11-26 00:16:57 +10:00
Claes Nästén
82cb97d3e3 builtin ulimit checks
Adds checks for RLIMIT_NPROC, RLIMIT_RSS and RLIMIT_MEMLOCK not available
on all platforms.

darcs-hash:20051124111321-cac88-606a61ca0f3baa69115be658a056f42a5a9318ad.gz
2005-11-24 21:13:21 +10:00
axel
7d334914f7 Minor code tweaks
darcs-hash:20051123185743-ac50b-dc35b7f64e5416f3f2749edebd5235abb5bdff98.gz
2005-11-24 04:57:43 +10:00
axel
27a60f465d Change name of fishd log file
darcs-hash:20051123185710-ac50b-bd3e5d1664a4832bfee579a027bbce9ac6661b2d.gz
2005-11-24 04:57:10 +10:00
horeah
279159384e Added support for recursive wildcards
darcs-hash:20051123153503-b56f0-6d837388e8bbfdebba9a399f8374b3e8433e5a32.gz
2005-11-24 01:35:03 +10:00
axel
d748e05cb9 Make sure installation path is in PATH
darcs-hash:20051103162625-ac50b-e70d6bff6a83130cd905008e65da34984bf64a7b.gz
2005-11-04 02:26:25 +10:00
axel
d50c051eec Change quoting rules to POSIX style
darcs-hash:20051102164913-ac50b-d4b696394e13a2d4c787f8ee1a2b209317dddb51.gz
2005-11-03 02:49:13 +10:00
43 changed files with 1387 additions and 1027 deletions

View File

@@ -1,3 +1,4 @@
2005-10-03 Netocrat <netocrat@dodo.com.au>
* fishd.c, common.c: Make lock-file name include hostname for increased protection on shared NFS /tmp.

View File

@@ -1957,22 +1957,13 @@ static int builtin_complete( wchar_t **argv )
}
/**
The source builtin. Can be called through either 'source' or
'.'. Evaluates the contents of a file.
The . (dot) builtin, sometimes called source. Evaluates the contents of a file.
*/
static int builtin_source( wchar_t ** argv )
{
int fd;
int res;
/*
if( wcsstr( argv[1], L"fish_complete" ) )
{
fwprintf( stderr, L"Woot\n" );
return 0;
}
*/
if( (argv[1] == 0) || (argv[2]!=0) )
{

View File

@@ -83,7 +83,7 @@ static int parse_fill_indexes( array_list_t *indexes,
return -1;
}
while (iswblank(*src))
while (iswspace(*src))
{
src++;
}
@@ -105,7 +105,7 @@ static int parse_fill_indexes( array_list_t *indexes,
al_push(indexes, ind);
src = end;
count++;
while (iswblank(*src)) src++;
while (iswspace(*src)) src++;
}
return count;

View File

@@ -35,6 +35,10 @@ struct resource_t
Switch used on commandline to specify resource
*/
wchar_t switch_char;
/**
The implicit multiplier used when setting getting values
*/
int multiplier;
}
;
@@ -44,49 +48,55 @@ struct resource_t
const static struct resource_t resource_arr[] =
{
{
RLIMIT_CORE, L"Maximum size of core files created", L'c'
RLIMIT_CORE, L"Maximum size of core files created", L'c', 1024
}
,
{
RLIMIT_DATA, L"Maximum size of a processs data segment", L'd'
RLIMIT_DATA, L"Maximum size of a processs data segment", L'd', 1024
}
,
{
RLIMIT_FSIZE, L"Maximum size of files created by the shell", L'f'
RLIMIT_FSIZE, L"Maximum size of files created by the shell", L'f', 1024
}
,
#if HAVE_RLIMIT_MEMLOCK
{
RLIMIT_MEMLOCK, L"Maximum size that may be locked into memory", L'l', 1024
}
,
#endif
#if HAVE_RLIMIT_RSS
{
RLIMIT_RSS, L"Maximum resident set size", L'm', 1024
}
,
#endif
{
RLIMIT_NOFILE, L"Maximum number of open file descriptors", L'n', 1
}
,
{
RLIMIT_MEMLOCK, L"Maximum size that may be locked into memory", L'l'
RLIMIT_STACK, L"Maximum stack size", L's', 1024
}
,
{
RLIMIT_RSS, L"Maximum resident set size", L'm'
RLIMIT_CPU, L"Maximum amount of cpu time in seconds", L't', 1
}
,
#if HAVE_RLIMIT_NPROC
{
RLIMIT_NOFILE, L"Maximum number of open file descriptors", L'n'
}
,
{
RLIMIT_STACK, L"Maximum stack size", L's'
}
,
{
RLIMIT_CPU, L"Maximum amount of cpu time in seconds", L't'
}
,
{
RLIMIT_NPROC, L"Maximum number of processes available to a single user", L'u'
RLIMIT_NPROC, L"Maximum number of processes available to a single user", L'u', 1
}
,
#endif
#if HAVE_RLIMIT_AS
{
RLIMIT_AS, L"Maximum amount of virtual memory available to the shell", L'v'
RLIMIT_AS, L"Maximum amount of virtual memory available to the shell", L'v', 1024
}
,
#endif
{
0, 0
0, 0, 0, 0
}
}
;
@@ -96,13 +106,16 @@ const static struct resource_t resource_arr[] =
*/
static int get_multiplier( int what )
{
if( ( what == RLIMIT_NPROC ) ||
( what == RLIMIT_NOFILE ) ||
( what == RLIMIT_CPU ) )
int i;
for( i=0; resource_arr[i].desc; i++ )
{
return 1;
if( resource_arr[i].resource == what )
{
return resource_arr[i].multiplier;
}
}
return 1024;
return -1;
}
/**
@@ -365,14 +378,17 @@ int builtin_ulimit( wchar_t ** argv )
case L'f':
what=RLIMIT_FSIZE;
break;
#if HAVE_RLIMIT_MEMLOCK
case L'l':
what=RLIMIT_MEMLOCK;
break;
#endif
#if HAVE_RLIMIT_RSS
case L'm':
what=RLIMIT_RSS;
break;
#endif
case L'n':
what=RLIMIT_NOFILE;
@@ -385,10 +401,12 @@ int builtin_ulimit( wchar_t ** argv )
case L't':
what=RLIMIT_CPU;
break;
#if HAVE_RLIMIT_NPROC
case L'u':
what=RLIMIT_NPROC;
break;
#endif
#if HAVE_RLIMIT_AS
case L'v':

583
common.c
View File

@@ -13,6 +13,7 @@ parts of fish.
#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <wctype.h>
@@ -314,8 +315,7 @@ char **wcsv2strv( const wchar_t **in )
char **res = malloc( sizeof( char *)*(count+1));
if( res == 0 )
{
die_mem();
die_mem();
}
for( i=0; i<count; i++ )
@@ -353,8 +353,10 @@ wchar_t *wcsdupcat2( const wchar_t *a, ... )
wchar_t *res = malloc( sizeof(wchar_t)*(len +1 ));
if( res == 0 )
return 0;
{
die_mem();
}
wcscpy( res, a );
pos = wcslen(a);
while( (arg=va_arg(va2, wchar_t *) )!= 0 )
@@ -489,17 +491,6 @@ long wcstol(const wchar_t *nptr,
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
Appends src to string dst of size siz (unlike wcsncat, siz is the
full size of dst, not space left). At most siz-1 characters will be
copied. Always NUL terminates (unless siz <= wcslen(dst)). Returns
wcslen(src) + MIN(siz, wcslen(initial dst)). If retval >= siz,
truncation occurred.
This is the OpenBSD strlcat function, modified for wide characters,
and renamed to reflect this change.
*/
size_t
wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
{
@@ -552,14 +543,6 @@ wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
Copy src to string dst of size siz. At most siz-1 characters will
be copied. Always NUL terminates (unless siz == 0). Returns
wcslen(src); if retval >= siz, truncation occurred.
This is the OpenBSD strlcpy function, modified for wide characters,
and renamed to reflect this change.
*/
size_t
wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
{
@@ -591,9 +574,6 @@ wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
/* count does not include NUL */
}
/**
Fallback implementation if missing from libc
*/
wchar_t *wcsdup( const wchar_t *in )
{
size_t len=wcslen(in);
@@ -601,7 +581,6 @@ wchar_t *wcsdup( const wchar_t *in )
if( out == 0 )
{
die_mem();
}
memcpy( out, in, sizeof( wchar_t)*(len+1));
@@ -706,43 +685,25 @@ int my_wcswidth( const wchar_t *c )
wchar_t *quote_end( const wchar_t *in )
{
int level=1;
int offset = (*in != L'\"');
in++;
while(1)
switch( *in )
{
/* fwprintf( stderr, L"Check %c\n", *tok->buff );*/
switch( *in )
case '"':
{
case L'\\':
in++;
if( *in == L'\0' )
{
while(1)
{
in = wcschr( in+1, L'"' );
if( !in )
return 0;
}
break;
case L'\"':
case L'\'':
if( (((level+offset) % 2)?L'\"':L'\'') == *in )
{
level--;
}
else
{
level++;
}
break;
if( *(in-1) != L'\\' )
return (wchar_t *)in;
}
}
case '\'':
{
return wcschr( in+1, L'\'' );
}
if( (*in == L'\0') ||(level==0))
break;
in++;
}
return level?0:(wchar_t *)in;
return 0;
}
@@ -997,8 +958,10 @@ wchar_t *escape( const wchar_t *in,
}
wchar_t *unescape( const wchar_t * orig, int escape_special )
wchar_t *unescape( const wchar_t * orig, int unescape_special )
{
int mode = 0;
int in_pos, out_pos, len = wcslen( orig );
int c;
int bracket_count=0;
@@ -1007,194 +970,346 @@ wchar_t *unescape( const wchar_t * orig, int escape_special )
if( !in )
die_mem();
for( in_pos=0, out_pos=0; in_pos<len; prev=in[out_pos], out_pos++, in_pos++ )
for( in_pos=0, out_pos=0;
in_pos<len;
(prev=(out_pos>=0)?in[out_pos]:0), out_pos++, in_pos++ )
{
c = in[in_pos];
if( c == L'\\' )
switch( mode )
{
switch( in[++in_pos] )
/*
Mode 0 means unquoted string
*/
case 0:
{
case L'\0':
free(in);
return 0;
case L'n':
in[out_pos]=L'\n';
break;
case L'r':
in[out_pos]=L'\r';
break;
case L't':
in[out_pos]=L'\t';
break;
case L'b':
in[out_pos]=L'\b';
break;
case L'e':
in[out_pos]=L'\e';
break;
case L'u':
case L'U':
case L'x':
case L'o':
if( c == L'\\' )
{
int i;
wchar_t res=0;
int chars=2;
int base=16;
switch( in[in_pos] )
switch( in[++in_pos] )
{
case L'u':
base=16;
chars=4;
break;
case L'U':
base=16;
chars=8;
break;
case L'x':
base=16;
chars=2;
break;
case L'o':
base=8;
chars=3;
break;
}
for( i=0; i<chars; i++ )
{
int d = convert_digit( in[++in_pos],base);
if( d < 0 )
case L'\0':
{
in_pos--;
free(in);
return 0;
}
case L'n':
{
in[out_pos]=L'\n';
break;
}
res=(res*base)|d;
case L'r':
{
in[out_pos]=L'\r';
break;
}
case L't':
{
in[out_pos]=L'\t';
break;
}
case L'b':
{
in[out_pos]=L'\b';
break;
}
case L'e':
{
in[out_pos]=L'\e';
break;
}
case L'u':
case L'U':
case L'x':
case L'o':
{
int i;
wchar_t res=0;
int chars=2;
int base=16;
switch( in[in_pos] )
{
case L'u':
{
base=16;
chars=4;
break;
}
case L'U':
{
base=16;
chars=8;
break;
}
case L'x':
{
base=16;
chars=2;
break;
}
case L'o':
{
base=8;
chars=3;
break;
}
}
for( i=0; i<chars; i++ )
{
int d = convert_digit( in[++in_pos],base);
if( d < 0 )
{
in_pos--;
break;
}
res=(res*base)|d;
}
in[out_pos] = res;
break;
}
default:
{
in[out_pos]=in[in_pos];
break;
}
}
}
else
{
switch( in[in_pos]){
case L'~':
{
if( unescape_special && (in_pos == 0) )
{
in[out_pos]=HOME_DIRECTORY;
}
else
{
in[out_pos] = L'~';
}
break;
}
case L'%':
{
if( unescape_special && (in_pos == 0) )
{
in[out_pos]=PROCESS_EXPAND;
}
else
{
in[out_pos]=in[in_pos];
}
break;
}
case L'*':
{
if( unescape_special )
{
if( out_pos > 0 && in[out_pos-1]==ANY_STRING )
{
out_pos--;
in[out_pos] = ANY_STRING_RECURSIVE;
}
else
in[out_pos]=ANY_STRING;
}
else
{
in[out_pos]=in[in_pos];
}
break;
}
case L'?':
{
if( unescape_special )
{
in[out_pos]=ANY_CHAR;
}
else
{
in[out_pos]=in[in_pos];
}
break;
}
case L'$':
{
if( unescape_special )
{
in[out_pos]=VARIABLE_EXPAND;
}
else
{
in[out_pos]=in[in_pos];
}
break;
}
case L'{':
{
if( unescape_special )
{
bracket_count++;
in[out_pos]=BRACKET_BEGIN;
}
else
{
in[out_pos]=in[in_pos];
}
break;
}
case L'}':
{
if( unescape_special )
{
bracket_count--;
in[out_pos]=BRACKET_END;
}
else
{
in[out_pos]=in[in_pos];
}
break;
}
case L',':
{
if( unescape_special && bracket_count && prev!=BRACKET_SEP)
{
in[out_pos]=BRACKET_SEP;
}
else
{
in[out_pos]=in[in_pos];
}
break;
}
case L'\'':
{
mode = 1;
out_pos--;
break;
}
case L'\"':
{
mode = 2;
out_pos--;
break;
}
default:
{
in[out_pos] = in[in_pos];
break;
}
}
}
break;
}
/*
Mode 1 means single quoted string, i.e 'foo'
*/
case 1:
{
if( c == L'\'' )
{
out_pos--;
mode = 0;
}
else
{
in[out_pos] = in[in_pos];
}
break;
}
/*
Mode 2 means double quoted string, i.e. "foo"
*/
case 2:
{
switch( c )
{
case '"':
{
mode = 0;
out_pos--;
break;
}
case '\\':
{
switch( in[++in_pos] )
{
case L'\0':
{
free(in);
return 0;
}
case L'$':
{
in[out_pos]=in[in_pos];
break;
}
default:
{
in[out_pos++] = L'\\';
in[out_pos] = in[in_pos];
break;
}
}
break;
}
in[out_pos] = res;
break;
}
default:
in[out_pos]=in[in_pos];
break;
}
}
else
{
switch( in[in_pos]){
case L'~':
if( escape_special && (in_pos == 0) )
in[out_pos]=HOME_DIRECTORY;
else
in[out_pos] = L'~';
break;
case L'%':
if( escape_special && (in_pos == 0) )
in[out_pos]=PROCESS_EXPAND;
else
in[out_pos]=in[in_pos];
break;
case L'*':
if( escape_special )
case '$':
{
if( out_pos > 0 && in[out_pos-1]==ANY_STRING )
if( unescape_special )
{
out_pos--;
in[out_pos] = ANY_STRING_RECURSIVE;
in[out_pos]=VARIABLE_EXPAND_SINGLE;
}
else
in[out_pos]=ANY_STRING;
{
in[out_pos]=in[in_pos];
}
break;
}
else
in[out_pos]=in[in_pos];
break;
case L'?':
if( escape_special )
in[out_pos]=ANY_CHAR;
else
in[out_pos]=in[in_pos];
break;
case L'$':
if( escape_special )
in[out_pos]=VARIABLE_EXPAND;
else
in[out_pos]=in[in_pos];
break;
case L'{':
if( escape_special )
default:
{
bracket_count++;
in[out_pos]=BRACKET_BEGIN;
in[out_pos] = in[in_pos];
break;
}
else
in[out_pos]=in[in_pos];
break;
case L'}':
if( escape_special )
{
bracket_count--;
in[out_pos]=BRACKET_END;
}
else
in[out_pos]=in[in_pos];
break;
case L',':
if( escape_special && bracket_count && prev!=BRACKET_SEP)
{
in[out_pos]=BRACKET_SEP;
}
else
in[out_pos]=in[in_pos];
break;
case L'\'':
case L'\"':
{
wchar_t *end = quote_end( &in[in_pos] );
int len;
if( end == 0 )
{
free(in);
return 0;
}
len = end- &in[in_pos]-1;
if( escape_special)
in[out_pos++]=INTERNAL_SEPARATOR;
memmove( &in[out_pos], &in[in_pos+1], sizeof(wchar_t)*(len) );
in_pos += len+1;
out_pos += len-1;
if( escape_special)
in[++out_pos]=INTERNAL_SEPARATOR;
break;
}
default:
in[out_pos] = in[in_pos];
break;
}
break;
}
}
}
}
in[out_pos]=L'\0';
return in;
@@ -1310,13 +1425,13 @@ static char *gen_unique_nfs_filename( const char *filename )
pidlen = sprint_pid_t( getpid(), newname + orglen + 1 + hnlen + 1 );
newname[orglen + 1 + hnlen + 1 + pidlen] = '\0';
/* debug( 1, L"gen_unique_nfs_filename returning with: newname = \"%s\"; "
L"HOST_NAME_MAX = %d; hnlen = %d; orglen = %d; "
L"sizeof(pid_t) = %d; maxpiddigits = %d; malloc'd size: %d",
newname, (int)HOST_NAME_MAX, hnlen, orglen,
(int)sizeof(pid_t),
(int)(0.31 * sizeof(pid_t) * CHAR_BIT + 1),
(int)(orglen + 1 + hnlen + 1 +
(int)(0.31 * sizeof(pid_t) * CHAR_BIT + 1) + 1) ); */
L"HOST_NAME_MAX = %d; hnlen = %d; orglen = %d; "
L"sizeof(pid_t) = %d; maxpiddigits = %d; malloc'd size: %d",
newname, (int)HOST_NAME_MAX, hnlen, orglen,
(int)sizeof(pid_t),
(int)(0.31 * sizeof(pid_t) * CHAR_BIT + 1),
(int)(orglen + 1 + hnlen + 1 +
(int)(0.31 * sizeof(pid_t) * CHAR_BIT + 1) + 1) ); */
return newname;
}

View File

@@ -14,7 +14,10 @@
#include "util.h"
/**
Under curses, tputs expects an int (*func)(char) as its last parameter, but in ncurses, tputs expects a int (*func)(int) as its last parameter. tputs_arg_t is defined to always be what tputs expects. Hopefully.
Under curses, tputs expects an int (*func)(char) as its last
parameter, but in ncurses, tputs expects a int (*func)(int) as its
last parameter. tputs_arg_t is defined to always be what tputs
expects. Hopefully.
*/
#ifdef NCURSES_VERSION
@@ -24,7 +27,7 @@ typedef char tputs_arg_t;
#endif
/**
Maximum number of bytes in a utf-8 character
Maximum number of bytes used by a single utf-8 character
*/
#define MAX_UTF8_BYTES 6
@@ -39,11 +42,14 @@ typedef char tputs_arg_t;
*/
#define FISH_COLOR_RESET -2
/** Save the shell mode on startup so we can restore them on exit */
/**
Save the shell mode on startup so we can restore them on exit
*/
extern struct termios shell_modes;
/**
The character to use where the text has been truncated. Is an ellipsis on unicode system and a $ on other systems.
The character to use where the text has been truncated. Is an
ellipsis on unicode system and a $ on other systems.
*/
extern wchar_t ellipsis_char;
@@ -69,7 +75,8 @@ extern char *profile;
extern wchar_t *program_name;
/**
Take an array_list_t containing wide strings and converts them to a wchar_t **.
Take an array_list_t containing wide strings and converts them to a
single null-terminated wchar_t **.
*/
wchar_t **list_to_char_arr( array_list_t *l );
@@ -87,22 +94,26 @@ wchar_t **list_to_char_arr( array_list_t *l );
int fgetws2( wchar_t **buff, int *len, FILE *f );
/**
Sorts a list of wide strings according to the wcsfilecmp-function from the util library
Sorts a list of wide strings according to the wcsfilecmp-function
from the util library
*/
void sort_list( array_list_t *comp );
/**
Returns a newly allocated wide character string equivalent of the specified multibyte character string
Returns a newly allocated wide character string equivalent of the
specified multibyte character string
*/
wchar_t *str2wcs( const char *in );
/**
Returns a newly allocated multibyte character string equivalent of the specified wide character string
Returns a newly allocated multibyte character string equivalent of
the specified wide character string
*/
char *wcs2str( const wchar_t *in );
/**
Returns a newly allocated wide character string array equivalent of the specified multibyte character string array
Returns a newly allocated wide character string array equivalent of
the specified multibyte character string array
*/
char **wcsv2strv( const wchar_t **in );
@@ -112,17 +123,22 @@ char **wcsv2strv( const wchar_t **in );
wchar_t **strv2wcsv( const char **in );
/**
Returns a newly allocated concatenation of the specified wide character strings
Returns a newly allocated concatenation of the specified wide
character strings
*/
wchar_t *wcsdupcat( const wchar_t *a, const wchar_t *b );
/**
Returns a newly allocated concatenation of the specified wide character strings. The last argument must be a null pointer.
Returns a newly allocated concatenation of the specified wide
character strings. The last argument must be a null pointer.
*/
wchar_t *wcsdupcat2( const wchar_t *a, ... );
/**
Returns a newly allocated wide character string wich is a copy of the string in, but of length c or shorter. The returned string is always null terminated, and the null is not included in the string length.
Returns a newly allocated wide character string wich is a copy of
the string in, but of length c or shorter. The returned string is
always null terminated, and the null is not included in the string
length.
*/
wchar_t *wcsndup( const wchar_t *in, int c );
@@ -144,14 +160,32 @@ long wcstol(const wchar_t *nptr,
wchar_t **endptr,
int base);
size_t
wcslcat(wchar_t *dst, const wchar_t *src, size_t siz);
/**
Appends src to string dst of size siz (unlike wcsncat, siz is the
full size of dst, not space left). At most siz-1 characters will be
copied. Always NUL terminates (unless siz <= wcslen(dst)). Returns
wcslen(src) + MIN(siz, wcslen(initial dst)). If retval >= siz,
truncation occurred.
size_t
wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz);
This is the OpenBSD strlcat function, modified for wide characters,
and renamed to reflect this change.
*/
size_t wcslcat( wchar_t *dst, const wchar_t *src, size_t siz );
/**
Create a dublicate string. Wide string version of strdup.
Copy src to string dst of size siz. At most siz-1 characters will
be copied. Always NUL terminates (unless siz == 0). Returns
wcslen(src); if retval >= siz, truncation occurred.
This is the OpenBSD strlcpy function, modified for wide characters,
and renamed to reflect this change.
*/
size_t wcslcpy( wchar_t *dst, const wchar_t *src, size_t siz );
/**
Create a dublicate string. Wide string version of strdup. Will
automatically exit if out of memory.
*/
wchar_t *wcsdup(const wchar_t *in);
@@ -163,9 +197,22 @@ wchar_t *wcsdup(const wchar_t *in);
esoteric locales where uppercase and lowercase do not cleanly
transform between each other. Hopefully this should be fine since
fish only uses this function with one of the strings supplied by
fish and guaranteed to be a sane, english word.
fish and guaranteed to be a sane, english word. Using wcscasecmp on
a user-supplied string should be considered a bug.
*/
int wcscasecmp( const wchar_t *a, const wchar_t *b );
/**
Case insensitive string compare function. Wide string version of
strncasecmp.
This implementation of wcsncasecmp does not take into account
esoteric locales where uppercase and lowercase do not cleanly
transform between each other. Hopefully this should be fine since
fish only uses this function with one of the strings supplied by
fish and guaranteed to be a sane, english word. Using wcsncasecmp on
a user-supplied string should be considered a bug.
*/
int wcsncasecmp( const wchar_t *a, const wchar_t *b, int count );
/**
@@ -188,7 +235,11 @@ int wcwidth( wchar_t c );
int my_wcswidth( const wchar_t *c );
/**
This functions returns the end of a quoted substring. It can handle nested single and double quotes.
This functions returns the end of the quoted substring beginning at
\c in. It can handle both single and double quotes. Returns 0 on
error.
\param in the position of the opening quote
*/
wchar_t *quote_end( const wchar_t *in );
@@ -205,7 +256,7 @@ void error_reset();
/**
Set the locale, also change the ellipsis character
*/
void fish_setlocale(int category, const wchar_t *locale);
void fish_setlocale( int category, const wchar_t *locale );
/**
Checks if \c needle is included in the list of strings specified

View File

@@ -1,97 +0,0 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* CPU type */
#undef CPU
/* Documentation directory */
#undef DOCDIR
/* Define to 1 if you have the `futimes' function. */
#undef HAVE_FUTIMES
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `rt' library (-lrt). */
#undef HAVE_LIBRT
/* Define to 1 if you have the `socket' library (-lsocket). */
#undef HAVE_LIBSOCKET
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <ncurses.h> header file. */
#undef HAVE_NCURSES_H
/* Define to 1 if HAVE_RLIMIT_AS is defined in <sys/resource.h>. */
#undef HAVE_RLIMIT_AS
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <termio.h> header file. */
#undef HAVE_TERMIO_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `wcswidth' function. */
#undef HAVE_WCSWIDTH
/* Define to 1 if you have the `wcwidth' function. */
#undef HAVE_WCWIDTH
/* Define to 1 if you have the `wprintf' function. */
#undef HAVE_WPRINTF
/* Define to 1 if you have the file `AC_File'. */
#undef HAVE__PROC_SELF_STAT
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Installation directory */
#undef PREFIX
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* System configuration directory */
#undef SYSCONFDIR
/* Evil kludge to get Power based machines to work */
#undef TPUTS_KLUDGE

View File

@@ -1,5 +1,5 @@
# Process this file with autoconf to produce a configure script.
AC_INIT(fish,1.16.2,axel@liljencrantz.se)
AC_INIT(fish,1.17.0,axel@liljencrantz.se)
AC_CANONICAL_TARGET
@@ -64,7 +64,7 @@ AC_CHECK_FILES([/proc/self/stat])
AC_CHECK_FILE([/usr/pkg/lib],[AC_SUBST(LIBDIR,[-L/usr/pkg/lib\ -R/usr/pkg/lib])])
AC_CHECK_FILE([/usr/pkg/include],[AC_SUBST(INCLUDEDIR,[-I/usr/pkg/include])])
AC_CHECK_FUNCS( [wprintf futimes wcwidth wcswidth] )
AC_CHECK_FUNCS( [wprintf futimes wcwidth wcswidth getopt_long] )
AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h])
# Check for RLIMIT_AS in sys/resource.h.
@@ -79,6 +79,43 @@ else
AC_MSG_RESULT(no)
fi
# Check for RLIMIT_MEMLOCK in sys/resource.h.
AC_MSG_CHECKING([for RLIMIT_MEMLOCK in sys/resource.h])
AC_TRY_COMPILE([#include <sys/resource.h>],
[int tmp; tmp=RLIMIT_MEMLOCK;], have_rlimit_as=yes, have_rlimit_as=no)
if test "$have_rlimit_as" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_RLIMIT_MEMLOCK], [1],
[Define to 1 if HAVE_RLIMIT_MEMLOCK is defined in <sys/resource.h>.])
else
AC_MSG_RESULT(no)
fi
# Check for RLIMIT_RSS in sys/resource.h.
AC_MSG_CHECKING([for RLIMIT_RSS in sys/resource.h])
AC_TRY_COMPILE([#include <sys/resource.h>],
[int tmp; tmp=RLIMIT_RSS;], have_rlimit_as=yes, have_rlimit_as=no)
if test "$have_rlimit_as" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_RLIMIT_RSS], [1],
[Define to 1 if HAVE_RLIMIT_RSS is defined in <sys/resource.h>.])
else
AC_MSG_RESULT(no)
fi
# Check for RLIMIT_NPROC in sys/resource.h.
AC_MSG_CHECKING([for RLIMIT_NPROC in sys/resource.h])
AC_TRY_COMPILE([#include <sys/resource.h>],
[int tmp; tmp=RLIMIT_NPROC;], have_rlimit_as=yes, have_rlimit_as=no)
if test "$have_rlimit_as" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_RLIMIT_NPROC], [1],
[Define to 1 if HAVE_RLIMIT_NPROC is defined in <sys/resource.h>.])
else
AC_MSG_RESULT(no)
fi
AC_CHECK_LIB(socket, connect)
AC_CHECK_LIB(rt, nanosleep)

89
env.c
View File

@@ -45,7 +45,7 @@
/**
Command used to start fishd
*/
#define FISHD_CMD L"if which fishd >/dev/null; fishd ^/tmp/fish.%s.log; end"
#define FISHD_CMD L"if which fishd >/dev/null; fishd ^/tmp/fishd.%s.log; end"
/**
Value denoting a null string
@@ -343,43 +343,66 @@ void env_init()
if( !path )
{
env_set( L"PATH", L"/bin" ARRAY_SEP_STR L"/usr/bin", ENV_EXPORT | ENV_GLOBAL );
path = env_get( L"PATH" );
}
else
{
int i;
int i, j;
array_list_t l;
int has_bin=0, has_usr_bin=0;
al_init( &l );
expand_variable_array( path, &l );
debug( 3, L"PATH is %ls", path );
for( i=0; i<al_get_count( &l); i++ )
{
wchar_t * el = (wchar_t *)al_get( &l, i );
if( contains_str( el, L"/bin", L"/bin/", (void *)0) )
const wchar_t *path_el[] =
{
has_bin = 1;
L"/bin",
L"/usr/bin",
PREFIX L"/bin",
0
}
if( contains_str( el, L"/usr/bin", L"/usr/bin/", (void *)0) )
;
for( j=0; path_el[j]; j++ )
{
int has_el=0;
debug( 3, L"Check directory %ls", path_el[j] );
for( i=0; i<al_get_count( &l); i++ )
{
has_bin = 1;
wchar_t * el = (wchar_t *)al_get( &l, i );
size_t len = wcslen( el );
while( (len > 0) && (el[len-1]==L'/') )
len--;
if( (wcslen( path_el[j] ) == len) && (wcsncmp( el, path_el[j], len)==0) )
{
has_el = 1;
}
}
if( !has_el )
{
string_buffer_t b;
debug( 3, L"directory %ls was missing", path_el[j] );
sb_init( &b );
sb_append2( &b, path,
ARRAY_SEP_STR,
path_el[j],
(void *)0 );
env_set( L"PATH", (wchar_t *)b.buff, ENV_GLOBAL | ENV_EXPORT );
sb_destroy( &b );
path = env_get( L"PATH" );
}
}
if( !( has_bin && has_usr_bin ) )
{
string_buffer_t b;
sb_init( &b );
sb_append( &b, path );
if( !has_bin )
sb_append( &b, ARRAY_SEP_STR L"/bin" );
if( !has_usr_bin )
sb_append( &b, ARRAY_SEP_STR L"/usr/bin" );
env_set( L"PATH", (wchar_t *)b.buff, ENV_GLOBAL | ENV_EXPORT );
sb_destroy( &b );
}
debug( 3, L"After: PATH is %ls", path );
al_foreach( &l, (void (*)(const void *))&free );
al_destroy( &l );
@@ -569,8 +592,11 @@ void env_set( const wchar_t *key,
else
{
if( !proc_had_barrier)
{
proc_had_barrier=1;
env_universal_barrier();
}
if( env_universal_get( key ) )
{
int export = 0;
@@ -785,7 +811,11 @@ wchar_t *env_get( const wchar_t *key )
env = env->next;
}
if( !proc_had_barrier)
{
proc_had_barrier=1;
env_universal_barrier();
}
item = env_universal_get( key );
if( !item || (wcscmp( item, ENV_NULL )==0))
@@ -822,7 +852,11 @@ int env_exist( const wchar_t *key )
env = env->next;
}
if( !proc_had_barrier)
{
proc_had_barrier=1;
env_universal_barrier();
}
item = env_universal_get( key );
return item != 0;
@@ -1056,8 +1090,11 @@ static void export_func2( const void *k, const void *v, void *aux )
char **env_export_arr( int recalc)
{
if( recalc && !proc_had_barrier)
{
proc_had_barrier=1;
env_universal_barrier();
}
if( has_changed )
{
array_list_t uni;

View File

@@ -117,19 +117,16 @@ static int get_socket( int fork_ok )
if( connect( s, (struct sockaddr *)&local, len) == -1 )
{
close( s );
if( fork_ok )
if( fork_ok && start_fishd )
{
debug( 2, L"Could not connect to socket %d, starting fishd", s );
if( start_fishd )
{
start_fishd();
}
start_fishd();
return get_socket( 0 );
}
debug( 3, L"Could not connect to socket %d, already tried forking, giving up", s );
debug( 2, L"Could not connect to socket %d, already tried manual restart (or no command supplied), giving up", s );
return -1;
}
@@ -174,7 +171,7 @@ static void check_connection()
if( env_universal_server.killme )
{
debug( 2, L"Lost connection to universal variable server." );
debug( 3, L"Lost connection to universal variable server." );
close( env_universal_server.fd );
env_universal_server.fd = -1;
env_universal_server.killme=0;
@@ -193,7 +190,7 @@ static void reconnect()
if( get_socket_count >= RECONNECT_COUNT )
return;
debug( 2, L"Get new fishd connection" );
debug( 3, L"Get new fishd connection" );
init = 0;
env_universal_server.fd = get_socket(1);
@@ -262,6 +259,8 @@ int env_universal_read_all()
if( !init)
return 0;
debug( 3, L"env_universal_read_all()" );
if( env_universal_server.fd == -1 )
{
reconnect();
@@ -290,11 +289,13 @@ wchar_t *env_universal_get( const wchar_t *name )
if( !name )
return 0;
debug( 3, L"env_universal_get( \"%ls\" )", name );
return env_universal_common_get( name );
}
int env_universal_get_export( const wchar_t *name )
{
debug( 3, L"env_universal_get_export()" );
return env_universal_common_get_export( name );
}
@@ -305,7 +306,7 @@ void env_universal_barrier()
if( !init || ( env_universal_server.fd == -1 ))
return;
barrier_reply = 0;
/*
@@ -330,6 +331,7 @@ void env_universal_barrier()
if( env_universal_server.fd == -1 )
{
reconnect();
debug( 2, L"barrier interrupted, exiting" );
return;
}
@@ -347,6 +349,7 @@ void env_universal_barrier()
if( env_universal_server.fd == -1 )
{
reconnect();
debug( 2, L"barrier interrupted, exiting (2)" );
return;
}
FD_ZERO( &fds );
@@ -365,7 +368,7 @@ void env_universal_set( const wchar_t *name, const wchar_t *value, int export )
if( !init )
return;
debug( 3, L"env_universal_set( %ls, %ls )", name, value );
debug( 3, L"env_universal_set( \"%ls\", \"%ls\" )", name, value );
msg = create_message( export?SET_EXPORT:SET,
name,
@@ -388,8 +391,8 @@ void env_universal_remove( const wchar_t *name )
if( !init )
return;
debug( 2,
L"env_universal_remove( %ls )",
debug( 3,
L"env_universal_remove( \"%ls\" )",
name );
msg= create_message( ERASE, name, 0);

42
exec.c
View File

@@ -261,17 +261,13 @@ static void handle_child_io( io_data_t *io )
free_fd( io, io->fd );
}
/*
We don't mind if this fails, it is just a speculative close
to make sure no unexpected untracked fd causes us to fail
*/
close(io->fd);
switch( io->io_mode )
{
case IO_CLOSE:
close(io->fd);
break;
case IO_FILE:
{
if( (tmp=wopen( io->param1.filename,
io->param2.flags, 0777 ) )==-1 )
{
@@ -284,6 +280,8 @@ static void handle_child_io( io_data_t *io )
}
else if( tmp != io->fd)
{
close(io->fd);
if(dup2( tmp, io->fd ) == -1 )
{
debug( 1,
@@ -295,7 +293,11 @@ static void handle_child_io( io_data_t *io )
exec_close( tmp );
}
break;
}
case IO_FD:
{
close(io->fd);
/* debug( 3, L"Redirect fd %d in process %ls (%d) from fd %d",
io->fd,
p->actual_cmd,
@@ -311,10 +313,12 @@ static void handle_child_io( io_data_t *io )
exit(1);
}
break;
}
case IO_BUFFER:
case IO_PIPE:
{
close(io->fd);
/* debug( 3, L"Pipe fd %d in process %ls (%d) (Through fd %d)",
io->fd,
@@ -937,15 +941,23 @@ void exec( job_t *j )
case INTERNAL_FUNCTION:
{
int status = proc_get_last_status();
/*
Handle output from a block or function. This usually
means do nothing, but in the case of pipes, we have
to buffer such io, since otherwisethe internal pipe
to buffer such io, since otherwise the internal pipe
buffer might overflow.
*/
if( !io_buffer )
{
/*
No buffer, se we exit directly. This means we
have to manually set the exit status.
*/
if( p->next == 0 )
{
proc_set_last_status( j->negate?(status?0:1):status);
}
p->completed = 1;
break;
}
@@ -956,8 +968,6 @@ void exec( job_t *j )
if( io_buffer->param2.out_buffer->used != 0 )
{
pid = fork();
if( pid == 0 )
{
@@ -1040,7 +1050,6 @@ void exec( job_t *j )
{
debug( 3, L"Set status of %ls to %d using short circut", j->command, p->status );
proc_set_last_status( p->status );
proc_set_last_status( j->negate?(p->status?0:1):p->status );
}
break;
@@ -1089,10 +1098,7 @@ void exec( job_t *j )
case EXTERNAL:
{
// fwprintf( stderr,
// L"fork on %ls\n", j->command );
pid = fork ();
pid = fork();
if( pid == 0 )
{
/*
@@ -1110,8 +1116,8 @@ void exec( job_t *j )
{
/* The fork failed. */
debug( 0, FORK_ERROR );
wperror (L"fork");
exit (1);
wperror( L"fork" );
exit( 1 );
}
else
{

305
expand.c
View File

@@ -92,23 +92,29 @@ parameter expansion.
any tokens which need to be expanded or otherwise altered. Clean
strings can be passed through expand_string and expand_one without
changing them. About 90% of all strings are clean, so skipping
expantion on them actually does save a small amount of time.
expantion on them actually does save a small amount of time, since
it avoids multiple memory allocations during the expantion process.
*/
static int is_clean( const wchar_t *in )
{
const wchar_t * str = in;
/*
Test characters that have a special meaning in the first character position
*/
if( wcschr( UNCLEAN_FIRST, *str ) )
return 0;
/*
Test characters that have a special meaning in any character position
*/
while( *str )
{
if( wcschr( UNCLEAN, *str ) )
return 0;
str++;
}
// debug( 1, L"%ls", in );
return 1;
}
@@ -120,7 +126,7 @@ static wchar_t *expand_var( wchar_t *in )
{
if( !in )
return 0;
return (in[0] == VARIABLE_EXPAND )? env_get( expand_var(in+1) ) : env_get( in );
return env_get( in );
}
void expand_variable_array( const wchar_t *val, array_list_t *out )
@@ -133,7 +139,6 @@ void expand_variable_array( const wchar_t *val, array_list_t *out )
if( !cpy )
{
die_mem();
}
for( start=pos=cpy; *pos; pos++ )
@@ -146,7 +151,7 @@ void expand_variable_array( const wchar_t *val, array_list_t *out )
}
}
al_push( out, wcsdup(start) );
free(cpy);
}
}
@@ -196,7 +201,7 @@ wchar_t *expand_escape_variable( const wchar_t *in )
switch( al_get_count( &l) )
{
case 0:
sb_append( &buff, L"\'\'");
sb_append( &buff, L"''");
break;
case 1:
@@ -206,9 +211,9 @@ wchar_t *expand_escape_variable( const wchar_t *in )
if( wcschr( el, L' ' ) && is_quotable( el ) )
{
sb_append2( &buff,
L"\'",
L"'",
el,
L"\'",
L"'",
(void *)0 );
}
else
@@ -232,9 +237,9 @@ wchar_t *expand_escape_variable( const wchar_t *in )
if( is_quotable( el ) )
{
sb_append2( &buff,
L"\'",
L"'",
el,
L"\'",
L"'",
(void *)0 );
}
else
@@ -335,7 +340,8 @@ static int match_pid( const wchar_t *cmd,
Searches for a job with the specified job id, or a job or process
which has the string \c proc as a prefix of its commandline.
If accept_incomplete is true, the remaining string for any matches are inserted.
If accept_incomplete is true, the remaining string for any matches
are inserted.
If accept_incomplete is false, any job matching the specified
string is matched, and the job pgid is returned. If no job
@@ -358,8 +364,6 @@ static int find_process( const wchar_t *proc,
wchar_t *result;
job_t *j;
if( iswnumeric(proc) || (wcslen(proc)==0) )
{
@@ -693,11 +697,10 @@ static int expand_variables( wchar_t *in, array_list_t *out )
int is_ok= 1;
int empty=0;
for( i=wcslen(in)-1; (i>=0) && is_ok && !empty; i-- )
{
c = in[i];
if( c == VARIABLE_EXPAND )
if( ( c == VARIABLE_EXPAND ) || (c == VARIABLE_EXPAND_SINGLE ) )
{
int start_pos = i+1;
int stop_pos;
@@ -706,15 +709,8 @@ static int expand_variables( wchar_t *in, array_list_t *out )
wchar_t * var_val;
wchar_t * new_in;
array_list_t l;
// fwprintf( stderr, L"Expand %ls\n", in );
// while (in[stop_pos]==VARIABLE_EXPAND)
// stop_pos++;
int is_single = (c==VARIABLE_EXPAND_SINGLE);
stop_pos = start_pos;
while( 1 )
@@ -736,95 +732,122 @@ static int expand_variables( wchar_t *in, array_list_t *out )
{
die_mem();
}
else
{
wcsncpy( var_name, &in[start_pos], var_len );
var_name[var_len]='\0';
wcsncpy( var_name, &in[start_pos], var_len );
var_name[var_len]='\0';
/* printf( "Variable name is %s, len is %d\n", var_name, var_len );*/
wchar_t *var_val_orig = expand_var( var_name );
wchar_t *var_val_orig = expand_var( var_name );
if( var_val_orig && (var_val = wcsdup( var_val_orig) ) )
{
int all_vars=1;
array_list_t idx;
al_init( &idx );
al_init( &l );
if( var_val_orig && (var_val = wcsdup( var_val_orig) ) )
{
int all_vars=1;
array_list_t idx;
al_init( &idx );
al_init( &l );
if( in[stop_pos] == L'[' )
{
wchar_t *end;
if( in[stop_pos] == L'[' )
{
wchar_t *end;
all_vars = 0;
all_vars = 0;
stop_pos++;
while( 1 )
stop_pos++;
while( 1 )
{
int tmp;
while( iswspace(in[stop_pos]) || (in[stop_pos]==INTERNAL_SEPARATOR))
stop_pos++;
if( in[stop_pos] == L']' )
{
int tmp;
while( iswspace(in[stop_pos]) || (in[stop_pos]==INTERNAL_SEPARATOR))
stop_pos++;
if( in[stop_pos] == L']' )
{
stop_pos++;
break;
}
stop_pos++;
break;
}
errno=0;
tmp = wcstol( &in[stop_pos], &end, 10 );
if( ( errno ) || ( end == &in[stop_pos] ) )
{
error( SYNTAX_ERROR,
L"Expected integer or \']\'",
-1 );
is_ok = 0;
break;
}
al_push( &idx, (void *)tmp );
stop_pos = end-in;
errno=0;
tmp = wcstol( &in[stop_pos], &end, 10 );
if( ( errno ) || ( end == &in[stop_pos] ) )
{
error( SYNTAX_ERROR,
L"Expected integer or \']\'",
-1 );
is_ok = 0;
break;
}
al_push( &idx, (void *)tmp );
stop_pos = end-in;
}
}
if( is_ok )
{
expand_variable_array( var_val, &l );
if( !all_vars )
{
int j;
for( j=0; j<al_get_count( &idx ); j++)
if( is_ok )
{
expand_variable_array( var_val, &l );
if( !all_vars )
{
int j;
for( j=0; j<al_get_count( &idx ); j++)
{
int tmp = (int)al_get( &idx, j );
if( tmp < 1 || tmp > al_get_count( &l ) )
{
int tmp = (int)al_get( &idx, j );
if( tmp < 1 || tmp > al_get_count( &l ) )
{
error( SYNTAX_ERROR, L"Array index out of bounds", -1 );
is_ok=0;
al_truncate( &idx, j );
break;
}
else
{
/* Move string from list l to list idx */
al_set( &idx, j, al_get( &l, tmp-1 ) );
al_set( &l, tmp-1, 0 );
}
error( SYNTAX_ERROR, L"Array index out of bounds", -1 );
is_ok=0;
al_truncate( &idx, j );
break;
}
else
{
/* Move string from list l to list idx */
al_set( &idx, j, al_get( &l, tmp-1 ) );
al_set( &l, tmp-1, 0 );
}
/* Free remaining strings in list l and truncate it */
al_foreach( &l, (void (*)(const void *))&free );
al_truncate( &l, 0 );
/* Add items from list idx back to list l */
al_push_all( &l, &idx );
}
free( var_val );
}
/* Free remaining strings in list l and truncate it */
al_foreach( &l, (void (*)(const void *))&free );
al_truncate( &l, 0 );
/* Add items from list idx back to list l */
al_push_all( &l, &idx );
}
free( var_val );
}
if( is_single )
{
string_buffer_t res;
sb_init( &res );
in[i]=0;
sb_append( &res, in );
for( j=0; j<al_get_count( &l); j++ )
{
wchar_t *next = (wchar_t *)al_get( &l, j );
if( is_ok )
{
if( j != 0 )
sb_append( &res, L" " );
sb_append( &res, next );
}
free( next );
}
sb_append( &res, &in[stop_pos] );
is_ok &= expand_variables( wcsdup((wchar_t *)res.buff), out );
sb_destroy( &res );
}
else
{
for( j=0; j<al_get_count( &l); j++ )
{
wchar_t *next = (wchar_t *)al_get( &l, j );
if( is_ok )
{
new_len = wcslen(in) - (stop_pos-start_pos+1) + wcslen( next) +2;
if( !(new_in = malloc( sizeof(wchar_t)*new_len )))
@@ -853,21 +876,54 @@ static int expand_variables( wchar_t *in, array_list_t *out )
}
}
free( next );
}
al_destroy( &l );
al_destroy( &idx );
free(in);
free(var_name );
return is_ok;
}
}
al_destroy( &l );
al_destroy( &idx );
free(in);
free(var_name );
return is_ok;
}
else
{
/*
Expand a non-existing variable
*/
if( c == VARIABLE_EXPAND )
{
/*
Regular expantion, i.e. expand this argument to nothing
*/
empty = 1;
}
else
{
empty = 1;
/*
Expantion to single argument.
*/
string_buffer_t res;
sb_init( &res );
in[i]=0;
sb_append( &res, in );
sb_append( &res, &in[stop_pos] );
is_ok &= expand_variables( wcsdup((wchar_t *)res.buff), out );
sb_destroy( &res );
free(in);
free(var_name );
return is_ok;
}
free(var_name );
}
free(var_name );
}
prev_char = c;
}
@@ -1197,20 +1253,19 @@ wchar_t *expand_unescape( const wchar_t * in, int escape_special )
/**
Attempts tilde expansion. Of the string specified. If tilde
expansion is performed, the argument is freed and a new string is
allocated in its place. Horrible call signature. Should be
altered. Fugly!
expansion is performed, the original string is freed and a new
string allocated using malloc is returned, otherwise, the original
string is returned.
*/
static int tilde_expand( wchar_t **ptr )
static wchar_t * expand_tilde_internal( wchar_t *in )
{
wchar_t *in = *ptr;
if( in[0] == HOME_DIRECTORY )
{
int tilde_error = 0;
wchar_t *home=0;
wchar_t *new_in;
wchar_t *old_in;
wchar_t *new_in=0;
wchar_t *old_in=0;
// fwprintf( stderr, L"Tilde expand ~%ls\n", (*ptr)+1 );
if( in[1] == '/' || in[1] == '\0' )
@@ -1267,26 +1322,23 @@ static int tilde_expand( wchar_t **ptr )
free(name);
}
if( !tilde_error )
if( !tilde_error && home && old_in )
{
new_in = wcsdupcat( home, old_in );
free( in );
in = new_in;
free(home);
*ptr = in;
}
}
free(home);
free( in );
return new_in;
}
return 1;
return in;
}
wchar_t *expand_tilde(wchar_t *in)
wchar_t *expand_tilde( wchar_t *in)
{
if( in[0] == L'~' )
{
in[0] = HOME_DIRECTORY;
tilde_expand( &in );
return in;
return expand_tilde_internal( in );
}
return in;
}
@@ -1300,8 +1352,6 @@ static void remove_internal_separator( const void *s, int conv )
wchar_t *in = (wchar_t *)s;
wchar_t *out=in;
// int changed=0;
while( *in )
{
switch( *in )
@@ -1325,16 +1375,11 @@ static void remove_internal_separator( const void *s, int conv )
}
}
*out=0;
/* if( changed )
{
fwprintf( stderr, L" -> %ls\n", s );
}
*/
}
/**
The real expansion function. All other expansion functions are wrappers to this one.
The real expantion function. expand_one is just a wrapper around this one.
*/
int expand_string( wchar_t *str,
array_list_t *end_out,
@@ -1400,7 +1445,7 @@ int expand_string( wchar_t *str,
1);
free( (void *)al_get( in, i ) );
if( !next )
continue;
@@ -1447,7 +1492,7 @@ int expand_string( wchar_t *str,
for( i=0; i<al_get_count( in ); i++ )
{
wchar_t *next = (wchar_t *)al_get( in, i );
if(!tilde_expand( &next ))
if( !(next=expand_tilde_internal( next ) ) )
{
al_destroy( in );
al_destroy( out );

View File

@@ -70,6 +70,9 @@ enum
/** Character representing variable expantion */
VARIABLE_EXPAND,
/** Character rpresenting variable expantion into a single element*/
VARIABLE_EXPAND_SINGLE,
/** Character representing the start of a bracket expantion */
BRACKET_BEGIN,

View File

@@ -69,6 +69,9 @@ fi
%config %_sysconfdir/fish.d/completions/*.fish
%changelog
* Tue Nov 29 2005 Axel Liljencrantz <axel@liljencrantz.se> 1.17.0-0
- 1.17.0
* Sat Sep 24 2005 Axel Liljencrantz <axel@liljencrantz.se> 1.14.0-0
- 1.14.0

60
fishd.c
View File

@@ -70,6 +70,11 @@ static connection_t *conn;
*/
static int sock;
/**
Set to one when fishd should save and exit
*/
static int quit=0;
/**
Constructs the fish socket filename
*/
@@ -110,6 +115,15 @@ static char *get_socket_filename()
return name;
}
/**
Signal handler for the term signal.
*/
static void handle_term( int signal )
{
quit=1;
}
/**
Acquire the lock for the socket
Returns the name of the lock file if successful or
@@ -268,26 +282,37 @@ static void daemonize()
case 0:
{
/*
Make fishd ignore the HUP signal.
*/
struct sigaction act;
sigemptyset( & act.sa_mask );
act.sa_flags=0;
act.sa_handler=SIG_IGN;
sigaction( SIGHUP, &act, 0);
/*
Make fishd save and exit on the TERM signal.
*/
sigfillset( & act.sa_mask );
act.sa_flags=0;
act.sa_handler=&handle_term;
sigaction( SIGTERM, &act, 0);
break;
}
default:
{
debug( 0, L"Parent calling exit" );
debug( 0, L"Parent process exiting (This is normal)" );
exit(0);
}
}
/*
Put ourself in out own processing group
*/
setsid();
/*
Close stdin and stdout. We only use stderr, anyway.
*/
@@ -386,8 +411,9 @@ static void init()
*/
int main( int argc, char ** argv )
{
int child_socket, t;
int child_socket;
struct sockaddr_un remote;
socklen_t t;
int max_fd;
int update_count=0;
@@ -416,15 +442,27 @@ int main( int argc, char ** argv )
FD_SET( c->fd, &write_fd );
}
}
res=select( max_fd, &read_fd, &write_fd, 0, 0 );
if( res==-1 )
while( 1 )
{
wperror( L"select" );
exit(1);
res=select( max_fd, &read_fd, &write_fd, 0, 0 );
if( quit )
{
save();
exit(0);
}
if( res != -1 )
break;
if( errno != EINTR )
{
wperror( L"select" );
exit(1);
}
}
if( FD_ISSET( sock, &read_fd ) )
{
if( (child_socket =

View File

@@ -58,7 +58,7 @@ void function_set_desc( const wchar_t *name, const wchar_t *desc );
/**
Returns true if the function witrh the name name exists.
*/
int function_exists( const wchar_t *name);
int function_exists( const wchar_t *name );
/**
Insert all function names into l. These are not copies of the strings and should not be freed after use.

View File

@@ -1,11 +1,12 @@
function __fish_complete_apropos
if test (commandline -ct)
set str (commandline -ct)
apropos $str|sed -e 's/^\(.*'$str'\([^ ]*\).*\)$/'$str'\2\t\1/'
apropos $str|sed -e "s/^\(.*$str\([^ ]*\).*\)$/$str\2\t\1/"
end
end
complete -xc apropos -a "(__fish_complete_apropos)" -d "Whatis entry"
complete -xc apropos -a '(__fish_complete_apropos)' -d "Whatis entry"
complete -c apropos -s h -l help -d "apropos command help"
complete -f -c apropos -s d -l debug -d "print debugging info"
@@ -14,7 +15,7 @@ complete -f -c apropos -s r -l regex -d "keyword as regex"
complete -f -c apropos -s w -l wildcard -d "keyword as wildwards"
complete -f -c apropos -s e -l exact -d "keyword as exactly match"
complete -x -c apropos -s m -l system -d "search for other system"
complete -x -c apropos -s M -l manpath -a "(echo $MANPATH)" -d "specify man path"
complete -x -c apropos -s M -l manpath -a '(echo $MANPATH)' -d "specify man path"
complete -x -c apropos -s C -l config-file -d "specify a conf file"
complete -f -c apropos -s V -l version -d "Display version"

View File

@@ -1,6 +1,6 @@
#completion for apt-get
function __fish_apt_no_subcommand -d "test if apt has yet to be given the subcommand"
function __fish_apt_no_subcommand -d 'test if apt has yet to be given the subcommand'
for i in (commandline -opc)
if contains -- $i update upgrade dselect-upgrade dist-upgrade install remove source build-dep check clean autoclean
return 1
@@ -9,7 +9,7 @@ function __fish_apt_no_subcommand -d "test if apt has yet to be given the subcom
return 0
end
function __fish_apt_use_package -d "Test if apt command should have packages as potential completion"
function __fish_apt_use_package -d 'Test if apt command should have packages as potential completion'
for i in (commandline -opc)
if contains -- $i contains install remove build-dep
return 0
@@ -18,47 +18,47 @@ function __fish_apt_use_package -d "Test if apt command should have packages as
return 1
end
complete -c apt-get -n "__fish_apt_use_package" -a "(__fish_print_packages)" -d "Package"
complete -c apt-get -n '__fish_apt_use_package' -a '(__fish_print_packages)' -d 'Package'
complete -c apt-get -s h -l help -d "apt-get command help"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "update" -d "update sources"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "upgrade" -d "upgrade or install newest packages"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "dselect-upgrade" -d "use with dselect front-end"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "dist-upgrade" -d "distro upgrade"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "install" -d "install one or more packages"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "remove" -d "remove one or more packages"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "source" -d "fetch source packages"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "build-dep" -d "install/remove packages for dependencies"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "check" -d "update cache and check dep"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "clean" -d "clean local caches and packages"
complete -f -n "__fish_apt_no_subcommand" -c apt-get -a "autoclean" -d "clean packages no longer be downloaded"
complete -c apt-get -s d -l download-only -d "Download Only"
complete -c apt-get -s f -l fix-broken -d "correct broken deps"
complete -c apt-get -s m -l fix-missing -d "ignore missing packages"
complete -c apt-get -l no-download -d "Disable downloading packages"
complete -c apt-get -s q -l quiet -d "quiet output"
complete -c apt-get -s s -l simulate -d "perform a siulation"
complete -c apt-get -s y -l assume-yes -d "automatic yes to prompts"
complete -c apt-get -s u -l show-upgraded -d "show upgraded packages"
complete -c apt-get -s V -l verbose-versions -d "show full versions for packages"
complete -c apt-get -s b -l compile -d "compile source packages"
complete -c apt-get -s b -l build -d "compile source packages"
complete -c apt-get -l ignore-hold -d "ignore package Holds"
complete -c apt-get -l no-upgrade -d "Do not upgrade packages"
complete -c apt-get -l force-yes -d "Force yes"
complete -c apt-get -l print-uris -d "print the URIs"
complete -c apt-get -l purge -d "use purge instead of remove"
complete -c apt-get -l reinstall -d "reinstall packages"
complete -c apt-get -l list-cleanup -d "erase obsolete files"
complete -c apt-get -s t -l target-release -d "control default input to the policy engine"
complete -c apt-get -l trivial-only -d "only perform operations that are trivial"
complete -c apt-get -l no-remove -d "abort if any packages are to be removed"
complete -c apt-get -l only-source -d "only accept source packages"
complete -c apt-get -l diff-only -d "download only diff file"
complete -c apt-get -l tar-only -d "download only tar file"
complete -c apt-get -l arch-only -d "only process arch-dep build-deps"
complete -c apt-get -l allow-unauthenticated -d "ignore non-authenticated packages"
complete -c apt-get -s v -l version -d "show program version"
complete -r -c apt-get -s c -l config-file -d "specify a config file"
complete -r -c apt-get -s o -l option -d "set a config option"
complete -c apt-get -s h -l help -d 'apt-get command help'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'update' -d 'update sources'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'upgrade' -d 'upgrade or install newest packages'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'dselect-upgrade' -d 'use with dselect front-end'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'dist-upgrade' -d 'distro upgrade'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'install' -d 'install one or more packages'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'remove' -d 'remove one or more packages'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'source' -d 'fetch source packages'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'build-dep' -d 'install/remove packages for dependencies'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'check' -d 'update cache and check dep'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'clean' -d 'clean local caches and packages'
complete -f -n '__fish_apt_no_subcommand' -c apt-get -a 'autoclean' -d 'clean packages no longer be downloaded'
complete -c apt-get -s d -l download-only -d 'Download Only'
complete -c apt-get -s f -l fix-broken -d 'correct broken deps'
complete -c apt-get -s m -l fix-missing -d 'ignore missing packages'
complete -c apt-get -l no-download -d 'Disable downloading packages'
complete -c apt-get -s q -l quiet -d 'quiet output'
complete -c apt-get -s s -l simulate -d 'perform a siulation'
complete -c apt-get -s y -l assume-yes -d 'automatic yes to prompts'
complete -c apt-get -s u -l show-upgraded -d 'show upgraded packages'
complete -c apt-get -s V -l verbose-versions -d 'show full versions for packages'
complete -c apt-get -s b -l compile -d 'compile source packages'
complete -c apt-get -s b -l build -d 'compile source packages'
complete -c apt-get -l ignore-hold -d 'ignore package Holds'
complete -c apt-get -l no-upgrade -d 'Do not upgrade packages'
complete -c apt-get -l force-yes -d 'Force yes'
complete -c apt-get -l print-uris -d 'print the URIs'
complete -c apt-get -l purge -d 'use purge instead of remove'
complete -c apt-get -l reinstall -d 'reinstall packages'
complete -c apt-get -l list-cleanup -d 'erase obsolete files'
complete -c apt-get -s t -l target-release -d 'control default input to the policy engine'
complete -c apt-get -l trivial-only -d 'only perform operations that are trivial'
complete -c apt-get -l no-remove -d 'abort if any packages are to be removed'
complete -c apt-get -l only-source -d 'only accept source packages'
complete -c apt-get -l diff-only -d 'download only diff file'
complete -c apt-get -l tar-only -d 'download only tar file'
complete -c apt-get -l arch-only -d 'only process arch-dep build-deps'
complete -c apt-get -l allow-unauthenticated -d 'ignore non-authenticated packages'
complete -c apt-get -s v -l version -d 'show program version'
complete -r -c apt-get -s c -l config-file -d 'specify a config file'
complete -r -c apt-get -s o -l option -d 'set a config option'

View File

@@ -1,10 +1,10 @@
#apt-proxy-import
complete -c apt-proxy-import -s h -l help -d "apt-proxy-import command help"
complete -f -c apt-proxy-import -s V -l version -d "print version"
complete -f -c apt-proxy-import -s v -l verbose -d "verbose info"
complete -f -c apt-proxy-import -s q -l quiet -d "no message to STDOUT"
complete -f -c apt-proxy-import -s r -l recursive -d "recurse into subdir"
complete -r -c apt-proxy-import -s i -l import-dir -a "(ls -Fp|grep /$)" -d "dir to import"
complete -r -c apt-proxy-import -s u -l user -a "(__fish_complete_users)" -d "change to user"
complete -r -c apt-proxy-import -s d -l debug -d "debug level[default 0]"
complete -c apt-proxy-import -s h -l help -d 'apt-proxy-import command help'
complete -f -c apt-proxy-import -s V -l version -d 'print version'
complete -f -c apt-proxy-import -s v -l verbose -d 'verbose info'
complete -f -c apt-proxy-import -s q -l quiet -d 'no message to STDOUT'
complete -f -c apt-proxy-import -s r -l recursive -d 'recurse into subdir'
complete -r -c apt-proxy-import -s i -l import-dir -a '(ls -Fp|grep /$)' -d 'dir to import'
complete -r -c apt-proxy-import -s u -l user -a '(__fish_complete_users)' -d 'change to user'
complete -r -c apt-proxy-import -s d -l debug -d 'debug level[default 0]'

View File

@@ -1,10 +1,10 @@
#apt-show-source
complete -c apt-show-source -s h -l help -d "apt-show-source command help"
complete -r -c apt-show-source -l status-file -d "read pkg from FILE" -f
complete -r -c apt-show-source -o stf -d "read pkg from FILE" -f
complete -r -c apt-show-source -l list-dir -a "(ls -Fp .|grep /$) /var/lib/apt/lists" -d "specify APT list dir"
complete -r -c apt-show-source -o ld -a "(ls -Fp .|grep /$) /var/lib/apt/lists" -d "specify APT list dir"
complete -r -c apt-show-source -s p -l package -a "(apt-cache pkgnames)" -d "list PKG info"
complete -f -c apt-show-source -l version-only -d "print version only"
complete -f -c apt-show-source -s a -l all -d "print all src pkgs with version"
complete -f -c apt-show-source -s v -l verbose -d "verbose message"
complete -c apt-show-source -s h -l help -d 'apt-show-source command help'
complete -r -c apt-show-source -l status-file -d 'read pkg from FILE' -f
complete -r -c apt-show-source -o stf -d 'read pkg from FILE' -f
complete -r -c apt-show-source -l list-dir -a '(ls -Fp .|grep /$) /var/lib/apt/lists' -d 'specify APT list dir'
complete -r -c apt-show-source -o ld -a '(ls -Fp .|grep /$) /var/lib/apt/lists' -d 'specify APT list dir'
complete -r -c apt-show-source -s p -l package -a '(apt-cache pkgnames)' -d 'list PKG info'
complete -f -c apt-show-source -l version-only -d 'print version only'
complete -f -c apt-show-source -s a -l all -d 'print all src pkgs with version'
complete -f -c apt-show-source -s v -l verbose -d 'verbose message'

View File

@@ -1,14 +1,14 @@
#apt-show-versions
complete -c apt-show-source -s h -l help -d "apt-show-versions command help"
complete -r -c apt-show-versions -s p -l packages -a "(apt-cache pkgnames)" -d "print PKG versions"
complete -f -c apt-show-versions -s r -l regex -d "using regex"
complete -f -c apt-show-versions -s u -l upgradeable -d "print only upgradeable pkgs"
complete -f -c apt-show-versions -s a -l allversions -d "print all versions"
complete -f -c apt-show-versions -s b -l brief -d "print pkg name/distro"
complete -f -c apt-show-versions -s v -l verbose -d "print verbose info"
complete -f -c apt-show-versions -s i -l initialize -d "init or update cache only"
complete -r -c apt-show-versions -l status-file -d "read pkg from FILE"
complete -r -c apt-show-versions -o stf -d "read pkg from FILE"
complete -r -c apt-show-versions -l list-dir -a "(ls -Fp .|grep /$) /var/lib/apt/lists /var/state/apt/lists" -d "specify APT list dir"
complete -r -c apt-show-versions -o ld -a "(ls -Fp .|grep /$) /var/lib/apt/lists /var/state/apt/lists" -d "specify APT list dir"
complete -c apt-show-source -s h -l help -d 'apt-show-versions command help'
complete -r -c apt-show-versions -s p -l packages -a '(apt-cache pkgnames)' -d 'print PKG versions'
complete -f -c apt-show-versions -s r -l regex -d 'using regex'
complete -f -c apt-show-versions -s u -l upgradeable -d 'print only upgradeable pkgs'
complete -f -c apt-show-versions -s a -l allversions -d 'print all versions'
complete -f -c apt-show-versions -s b -l brief -d 'print pkg name/distro'
complete -f -c apt-show-versions -s v -l verbose -d 'print verbose info'
complete -f -c apt-show-versions -s i -l initialize -d 'init or update cache only'
complete -r -c apt-show-versions -l status-file -d 'read pkg from FILE'
complete -r -c apt-show-versions -o stf -d 'read pkg from FILE'
complete -r -c apt-show-versions -l list-dir -a '(ls -Fp .|grep /$) /var/lib/apt/lists /var/state/apt/lists' -d 'specify APT list dir'
complete -r -c apt-show-versions -o ld -a '(ls -Fp .|grep /$) /var/lib/apt/lists /var/state/apt/lists' -d 'specify APT list dir'

View File

@@ -1,12 +1,12 @@
complete -c cat -s A -l show-all -d "Escape all non-printing characters"
complete -c cat -s b -l number-nonblank -d "Number nonblank lines"
complete -c cat -s e -d "Escape non-printing characters except tab"
complete -c cat -s E -l show-ends -d "Display $ at end of line"
complete -c cat -s n -l number -d "Number all lines"
complete -c cat -s s -l squeeze-blank -d "Never more than single blank line"
complete -c cat -s t -d "Escape non-printing characters except newline"
complete -c cat -s T -l show-tabs -d "Escape tab"
complete -c cat -s v -d "Escape non-printing except newline and tab"
complete -c cat -l help -d "Display help and exit"
complete -c cat -l version -d "Display version and exit"
complete -c cat -s A -l show-all -d 'Escape all non-printing characters'
complete -c cat -s b -l number-nonblank -d 'Number nonblank lines'
complete -c cat -s e -d 'Escape non-printing characters except tab'
complete -c cat -s E -l show-ends -d 'Display $ at end of line'
complete -c cat -s n -l number -d 'Number all lines'
complete -c cat -s s -l squeeze-blank -d 'Never more than single blank line'
complete -c cat -s t -d 'Escape non-printing characters except newline'
complete -c cat -s T -l show-tabs -d 'Escape tab'
complete -c cat -s v -d 'Escape non-printing except newline and tab'
complete -c cat -l help -d 'Display help and exit'
complete -c cat -l version -d 'Display version and exit'

View File

@@ -2,52 +2,52 @@
# I don't use CVS, so these completions are probably not all that good.
#
complete -c cvs -x -a "add" -d "Add a new file/directory to the repository"
complete -c cvs -x -a "admin" -d "Administration front end for rcs"
complete -c cvs -x -a "annotate" -d "Show last revision where each line was modified"
complete -c cvs -x -a "checkout" -d "Checkout sources for editing"
complete -c cvs -x -a "commit" -d "Check files into the repository"
complete -c cvs -x -a "diff" -d "Show differences between revisions"
complete -c cvs -x -a "edit" -d "Get ready to edit a watched file"
complete -c cvs -x -a "editors" -d "See who is editing a watched file"
complete -c cvs -x -a "export" -d "Export sources from CVS, similar to checkout"
complete -c cvs -x -a "history" -d "Show repository access history"
complete -c cvs -x -a "import" -d "Import sources into CVS, using vendor branches"
complete -c cvs -x -a "init" -d "Create a CVS repository if it doesnt exist"
complete -c cvs -x -a "kserver" -d "Kerberos server mode"
complete -c cvs -x -a "log" -d "Print out history information for files"
complete -c cvs -x -a "login" -d "Prompt for password for authenticating server"
complete -c cvs -x -a "logout" -d "Removes entry in .cvspass for remote repository"
complete -c cvs -x -a "pserver" -d "Password server mode"
complete -c cvs -x -a "rannotate" -d "Show last revision where each line of module was modified"
complete -c cvs -x -a "rdiff" -d "Create 'patch' format diffs between releases"
complete -c cvs -x -a "release" -d "Indicate that a Module is no longer in use"
complete -c cvs -x -a "remove" -d "Remove an entry from the repository"
complete -c cvs -x -a "rlog" -d "Print out history information for a module"
complete -c cvs -x -a "rtag" -d "Add a symbolic tag to a module"
complete -c cvs -x -a "server" -d "Server mode"
complete -c cvs -x -a "status" -d "Display status information on checked out files"
complete -c cvs -x -a "tag" -d "Add a symbolic tag to checked out version of files"
complete -c cvs -x -a "unedit" -d "Undo an edit command"
complete -c cvs -x -a "update" -d "Bring work tree in sync with repository"
complete -c cvs -x -a "version" -d "Show current CVS version(s)"
complete -c cvs -x -a "watch" -d "Set watches"
complete -c cvs -x -a "watchers" -d "See who is watching a file"
complete -c cvs -x -a 'add' -d 'Add a new file/directory to the repository'
complete -c cvs -x -a 'admin' -d 'Administration front end for rcs'
complete -c cvs -x -a 'annotate' -d 'Show last revision where each line was modified'
complete -c cvs -x -a 'checkout' -d 'Checkout sources for editing'
complete -c cvs -x -a 'commit' -d 'Check files into the repository'
complete -c cvs -x -a 'diff' -d 'Show differences between revisions'
complete -c cvs -x -a 'edit' -d 'Get ready to edit a watched file'
complete -c cvs -x -a 'editors' -d 'See who is editing a watched file'
complete -c cvs -x -a 'export' -d 'Export sources from CVS, similar to checkout'
complete -c cvs -x -a 'history' -d 'Show repository access history'
complete -c cvs -x -a 'import' -d 'Import sources into CVS, using vendor branches'
complete -c cvs -x -a 'init' -d 'Create a CVS repository if it doesnt exist'
complete -c cvs -x -a 'kserver' -d 'Kerberos server mode'
complete -c cvs -x -a 'log' -d 'Print out history information for files'
complete -c cvs -x -a 'login' -d 'Prompt for password for authenticating server'
complete -c cvs -x -a 'logout' -d 'Removes entry in .cvspass for remote repository'
complete -c cvs -x -a 'pserver' -d 'Password server mode'
complete -c cvs -x -a 'rannotate' -d 'Show last revision where each line of module was modified'
complete -c cvs -x -a 'rdiff' -d 'Create "patch" format diffs between releases'
complete -c cvs -x -a 'release' -d 'Indicate that a Module is no longer in use'
complete -c cvs -x -a 'remove' -d 'Remove an entry from the repository'
complete -c cvs -x -a 'rlog' -d 'Print out history information for a module'
complete -c cvs -x -a 'rtag' -d 'Add a symbolic tag to a module'
complete -c cvs -x -a 'server' -d 'Server mode'
complete -c cvs -x -a 'status' -d 'Display status information on checked out files'
complete -c cvs -x -a 'tag' -d 'Add a symbolic tag to checked out version of files'
complete -c cvs -x -a 'unedit' -d 'Undo an edit command'
complete -c cvs -x -a 'update' -d 'Bring work tree in sync with repository'
complete -c cvs -x -a 'version' -d 'Show current CVS version(s)'
complete -c cvs -x -a 'watch' -d 'Set watches'
complete -c cvs -x -a 'watchers' -d 'See who is watching a file'
complete -c cvs -x -s H -d "Displays usage information for command"
complete -c cvs -x -s Q -d "Cause CVS to be really quiet"
complete -c cvs -x -s q -d "Cause CVS to be somewhat quiet"
complete -c cvs -x -s r -d "Make checked-out files read-only"
complete -c cvs -x -s w -d "Make checked-out files read-write (default)"
complete -c cvs -x -s n -d "Do not execute anything that will change the disk"
complete -c cvs -x -s t -d "Show trace of program execution -- try with -n"
complete -c cvs -x -s v -d "CVS version and copyright"
complete -c cvs -x -s T -r -d "Use 'tmpdir' for temporary files"
complete -c cvs -x -s e -r -d "Use 'editor' for editing log information"
complete -c cvs -x -s d -r -d "Overrides $CVSROOT as the root of the CVS tree"
complete -c cvs -x -s f -d "Do not use the ~/.cvsrc file"
complete -c cvs -x -s z -d "Compression level for net traffic" -x -a "1 2 3 4 5 6 7 8 9"
complete -c cvs -x -s x -d "Encrypt all net traffic"
complete -c cvs -x -s a -d "Authenticate all net traffic"
complete -c cvs -x -s s -d "Set CVS user variable" -x
complete -c cvs -x -s H -d 'Displays usage information for command'
complete -c cvs -x -s Q -d 'Cause CVS to be really quiet'
complete -c cvs -x -s q -d 'Cause CVS to be somewhat quiet'
complete -c cvs -x -s r -d 'Make checked-out files read-only'
complete -c cvs -x -s w -d 'Make checked-out files read-write (default)'
complete -c cvs -x -s n -d 'Do not execute anything that will change the disk'
complete -c cvs -x -s t -d 'Show trace of program execution -- try with -n'
complete -c cvs -x -s v -d 'CVS version and copyright'
complete -c cvs -x -s T -r -d 'Use "tmpdir" for temporary files'
complete -c cvs -x -s e -r -d 'Use "editor" for editing log information'
complete -c cvs -x -s d -r -d 'Overrides $CVSROOT as the root of the CVS tree'
complete -c cvs -x -s f -d 'Do not use the ~/.cvsrc file'
complete -c cvs -x -s z -d 'Compression level for net traffic' -x -a '1 2 3 4 5 6 7 8 9'
complete -c cvs -x -s x -d 'Encrypt all net traffic'
complete -c cvs -x -s a -d 'Authenticate all net traffic'
complete -c cvs -x -s s -d 'Set CVS user variable' -x

View File

@@ -2,7 +2,7 @@
# The gcc completion list is incomplete. There are just so many of them...
#
complete -c gcc -s x -d "Language" -x -a "
complete -c gcc -s x -d 'Language' -x -a '
c
c-header
cpp-output
@@ -19,17 +19,17 @@ complete -c gcc -s x -d "Language" -x -a "
java
treelang
none
"
complete -c gcc -o pass-exit-codes -d "Pass program exit codes"
complete -c gcc -s c -d "Stop after assembler"
complete -c gcc -s S -d "Stop after compile"
complete -c gcc -s E -d "Stop after preprocesswor"
complete -c gcc -s o -r -d "Output file"
complete -c gcc -s v -d "Print commands to stderr"
complete -c gcc -o \#\#\# -d "Print quoted commands to stderr, do not run"
complete -c gcc -o pipe -d "Use pipes"
complete -c gcc -o ansi -d "Use ansi mode"
complete -c gcc -o std -d "Standard mode" -x -a '
'
complete -c gcc -o pass-exit-codes -d 'Pass program exit codes'
complete -c gcc -s c -d 'Stop after assembler'
complete -c gcc -s S -d 'Stop after compile'
complete -c gcc -s E -d 'Stop after preprocesswor'
complete -c gcc -s o -r -d 'Output file'
complete -c gcc -s v -d 'Print commands to stderr'
complete -c gcc -o \#\#\# -d 'Print quoted commands to stderr, do not run'
complete -c gcc -o pipe -d 'Use pipes'
complete -c gcc -o ansi -d 'Use ansi mode'
complete -c gcc -o std -d 'Standard mode' -x -a '
c89\t"ISO C90"
iso9899:1990\t"ISO C90"
iso9899:199409\t"ISO C90 as modified in amendment 1"
@@ -43,54 +43,54 @@ complete -c gcc -o std -d "Standard mode" -x -a '
c++98\t"ISO C++98"
gnu++98\t"ISO C++98 plus GNU extentions"
'
complete -c gcc -o aux-info -r -d "Write prototypes to file"
complete -c gcc -o fno-asm -d "Do not recognize asm, inline or typeof keywords"
complete -c gcc -o fno-builtin -d "Do not use builtin functions"
complete -c gcc -o fhosted -d "Assert hosted environment"
complete -c gcc -o ffreestanding -d "Assert freestanding environment"
complete -c gcc -o fms-extensions -d "Use Microsoft extensions"
complete -c gcc -o trigraphs -d "Use ANSI trigraphs"
complete -c gcc -o no-integrated-cpp -d "Do not use integrated preprocessor"
complete -c gcc -o funsigned-char -d "char is unsigned"
complete -c gcc -o fsigned-char -d "char is signed"
complete -c gcc -o funsigned-bitfields -d "bifield is unsigned"
complete -c gcc -o fsigned-bitfields -d "bifield is signed"
complete -c gcc -o fno-unsigned-bitfields -d "All bifields are signed"
complete -c gcc -o fno-signed-bitfields -d "All bifield are signed"
complete -c gcc -o fwritable-strings -d "String constants are not const"
complete -c gcc -o fabi-version -d "C++ ABI version" -r -x -a "1 0"
complete -c gcc -o fno-access-control -d "Turn off access checking"
complete -c gcc -o fcheck-new -d "Check pointer returned by new"
complete -c gcc -o fconserve-space -d "Put globals in the common segment"
complete -c gcc -o fno-const-strings -d "String constants are not const"
complete -c gcc -o fdollars-in-identifiers -d "Accept $ in identifiers"
complete -c gcc -o fno-dollars-in-identifiers -d "Reject $ in identifiers"
complete -c gcc -o fno-elide-constructors -d "Do not omit unneeded temporarys"
complete -c gcc -o fno-enforce-eh-specs -d "Allow exception violations"
complete -c gcc -o ffor-scope -d "Do not extend for-loop scope"
complete -c gcc -o fno-for-scope -d "Extend for-loop scope"
complete -c gcc -o fno-gnu-keywords -d "Do not recognize typeof as keyword"
complete -c gcc -o fno-implicit-templates -d "Do not emit code for implicit templates"
complete -c gcc -o fno-implicit-inline-templates -d "Do not emit code for implicit inline templates"
complete -c gcc -o fno-implement-inlines -d "Do not emit out-of-line code for inline functions"
complete -c gcc -o fms-extensions -d "Disable warnings about MFC"
complete -c gcc -o fno-nonansi-builtins -d "Disable some built-in functions"
complete -c gcc -o fno-operator-names -d "Disable operator keywords"
complete -c gcc -o fno-optional-diags -d "Disable optional diagnostics"
complete -c gcc -o fpermissive -d "Downgrade some errors to warnings"
complete -c gcc -o frepo -d "Enable automatic template instantiation at link time"
complete -c gcc -o fno-rtti -d "Disable generation of C++ runtime type information"
#complete -c gcc -o fstats -d "Emit front-end usage statistics"
complete -c gcc -o aux-info -r -d 'Write prototypes to file'
complete -c gcc -o fno-asm -d 'Do not recognize asm, inline or typeof keywords'
complete -c gcc -o fno-builtin -d 'Do not use builtin functions'
complete -c gcc -o fhosted -d 'Assert hosted environment'
complete -c gcc -o ffreestanding -d 'Assert freestanding environment'
complete -c gcc -o fms-extensions -d 'Use Microsoft extensions'
complete -c gcc -o trigraphs -d 'Use ANSI trigraphs'
complete -c gcc -o no-integrated-cpp -d 'Do not use integrated preprocessor'
complete -c gcc -o funsigned-char -d 'char is unsigned'
complete -c gcc -o fsigned-char -d 'char is signed'
complete -c gcc -o funsigned-bitfields -d 'bifield is unsigned'
complete -c gcc -o fsigned-bitfields -d 'bifield is signed'
complete -c gcc -o fno-unsigned-bitfields -d 'All bifields are signed'
complete -c gcc -o fno-signed-bitfields -d 'All bifield are signed'
complete -c gcc -o fwritable-strings -d 'String constants are not const'
complete -c gcc -o fabi-version -d 'C++ ABI version' -r -x -a '1 0'
complete -c gcc -o fno-access-control -d 'Turn off access checking'
complete -c gcc -o fcheck-new -d 'Check pointer returned by new'
complete -c gcc -o fconserve-space -d 'Put globals in the common segment'
complete -c gcc -o fno-const-strings -d 'String constants are not const'
complete -c gcc -o fdollars-in-identifiers -d 'Accept $ in identifiers'
complete -c gcc -o fno-dollars-in-identifiers -d 'Reject $ in identifiers'
complete -c gcc -o fno-elide-constructors -d 'Do not omit unneeded temporarys'
complete -c gcc -o fno-enforce-eh-specs -d 'Allow exception violations'
complete -c gcc -o ffor-scope -d 'Do not extend for-loop scope'
complete -c gcc -o fno-for-scope -d 'Extend for-loop scope'
complete -c gcc -o fno-gnu-keywords -d 'Do not recognize typeof as keyword'
complete -c gcc -o fno-implicit-templates -d 'Do not emit code for implicit templates'
complete -c gcc -o fno-implicit-inline-templates -d 'Do not emit code for implicit inline templates'
complete -c gcc -o fno-implement-inlines -d 'Do not emit out-of-line code for inline functions'
complete -c gcc -o fms-extensions -d 'Disable warnings about MFC'
complete -c gcc -o fno-nonansi-builtins -d 'Disable some built-in functions'
complete -c gcc -o fno-operator-names -d 'Disable operator keywords'
complete -c gcc -o fno-optional-diags -d 'Disable optional diagnostics'
complete -c gcc -o fpermissive -d 'Downgrade some errors to warnings'
complete -c gcc -o frepo -d 'Enable automatic template instantiation at link time'
complete -c gcc -o fno-rtti -d 'Disable generation of C++ runtime type information'
#complete -c gcc -o fstats -d 'Emit front-end usage statistics'
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17;
complete -c gcc -o ftemplate-depth-1 -d Set\ maximum\ template\ depth\ to\ $i;
end;
complete -c gcc -o fno-threadsafe-statistics -d "Do not emit code for thread-safe initialization of local statics"
complete -c gcc -o fuse-cxa-atexit -d "Use __cxa_atexit for destructors"
complete -c gcc -o fvisibility-inlines-hidden -d "Hides inline methods from export table"
complete -c gcc -o fno-weak -d "Do not use weak symbol support"
complete -c gcc -o fno-threadsafe-statistics -d 'Do not emit code for thread-safe initialization of local statics'
complete -c gcc -o fuse-cxa-atexit -d 'Use __cxa_atexit for destructors'
complete -c gcc -o fvisibility-inlines-hidden -d 'Hides inline methods from export table'
complete -c gcc -o fno-weak -d 'Do not use weak symbol support'
# gcc completion listing is incomplete.
#complete -c gcc -o -d ""
#complete -c gcc -o -d ''

View File

@@ -24,12 +24,12 @@ else
complete -c kill -s l -d "List codes and names of available signals"
for i in (kill -l|tr \ \t \n|grep "^[A-Z][A-Z0-9]*$")
for i in (kill -l|tr \ \t \n|grep '^[A-Z][A-Z0-9]*$')
complete -c kill -o $i -d Send\ $i\ signal
complete -c kill -o s -x -a $i\tSend\ $i\ signal -d "Send specified signal"
end
end
complete -c kill -xa "(__fish_complete_pids)"
complete -c kill -xa '(__fish_complete_pids)'
complete -c kill -s l -d "List names of available signals"

View File

@@ -17,7 +17,7 @@ complete -c less -s I -l IGNORE-CASE -d "Search ignores all case"
complete -c less -s j -l jump-target -d "Target line" -r -a "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19"
complete -c less -s J -l status-column -d "Display status column"
complete -c less -s k -l lesskey-file -d "Specify key bindings file" -r
complete -c less -s L -l no-lessopen -d "Ignore $LESSOPEN"
complete -c less -s L -l no-lessopen -d 'Ignore $LESSOPEN'
complete -c less -s m -l long-prompt -d "Prompt with percentage"
complete -c less -s M -l LONG-PROMPT -d "Verbose prompt"
complete -c less -s n -l line-numbers -d "Display line number"

View File

@@ -3,7 +3,7 @@
# A list of all known filesystem types, used by various completions,
# including mount and df
set -g __fish_filesystems "
set -g __fish_filesystems '
adfs
affs
autofs
@@ -39,29 +39,29 @@ set -g __fish_filesystems "
xenix
xfs
xiafs
"
'
# Completions for mount
complete -x -c mount -a "(cat /etc/fstab|sed -e 's/^\([^ \t]*\)[ \t]*\([^ \t]*\).*/\1\n\2/'|grep '^/')" -d "Mount point"
complete -c mount -s V -d "Display version and exit"
complete -c mount -s h -d "Display help and exit"
complete -c mount -s v -d "Verbose mode"
complete -c mount -s a -d "Mount filesystems in fstab"
complete -c mount -s F -d "Fork process for each mount"
complete -c mount -s f -d "Fake mounting"
complete -c mount -s l -d "Add label to output"
complete -c mount -s n -d "Do not write mtab"
complete -c mount -s s -d "Tolerate sloppy mount options"
complete -c mount -s r -d "Read only"
complete -c mount -s w -d "Read/Write mode"
complete -x -c mount -s L -d "Mount partition with specified label"
complete -x -c mount -s U -d "Mount partition with specified UID"
complete -c mount -s O -x -d "Exclude filesystems"
complete -c mount -l bind -f -d "Remount a subtree to a second position"
complete -c mount -l move -f -d "Move a subtree to a new position"
complete -c mount -x -s t -d "Filesystem" -a $__fish_filesystems
complete -x -c mount -a '(cat /etc/fstab|sed -e "s/^\([^ \t]*\)[ \t]*\([^ \t]*\).*/\1\n\2/"|grep "^/")' -d 'Mount point'
complete -c mount -s V -d 'Display version and exit'
complete -c mount -s h -d 'Display help and exit'
complete -c mount -s v -d 'Verbose mode'
complete -c mount -s a -d 'Mount filesystems in fstab'
complete -c mount -s F -d 'Fork process for each mount'
complete -c mount -s f -d 'Fake mounting'
complete -c mount -s l -d 'Add label to output'
complete -c mount -s n -d 'Do not write mtab'
complete -c mount -s s -d 'Tolerate sloppy mount options'
complete -c mount -s r -d 'Read only'
complete -c mount -s w -d 'Read/Write mode'
complete -x -c mount -s L -d 'Mount partition with specified label'
complete -x -c mount -s U -d 'Mount partition with specified UID'
complete -c mount -s O -x -d 'Exclude filesystems'
complete -c mount -l bind -f -d 'Remount a subtree to a second position'
complete -c mount -l move -f -d 'Move a subtree to a new position'
complete -c mount -x -s t -d 'Filesystem' -a $__fish_filesystems
complete -c mount -x -s o -d "Mount option" -a "(__fish_append ',' $__fish_mount_opts)"
complete -c mount -x -s o -d 'Mount option' -a '(__fish_append , $__fish_mount_opts)'
set -g __fish_mount_opts async\tUse\ asynchronous\ I/O atime\tUpdate\ time\ on\ each\ access auto\tMounted\ with\ -a defaults\tUse\ default\ options dev\tInterpret\ character/block\ special\ devices exec\tPermit\ executables _netdev\tFilesystem\ uses\network noatime\tDo\ not\ update\ time\ on\ each\ access noauto\tNot\ mounted\ by\ -a nodev\tDo\ not\ interpret\ character/block\ special\ devices noexec\tDo\ not\ permit\ executables nosuid\tIgnore\ suid\ bits nouser\tOnly\ root\ may\ mount remount\tRemount\ read-only\ filesystem ro\tMount\ read-only rw\tMount\ read-write suid\tAllow\ suid\ bits sync\tUse\ synchronous\ I/O dirsync\tUse\ synchronous\ directory\ operations user\tAny\ user\ may\ mount users\tAny\ user\ may\ mount\ and\ unmount

View File

@@ -1,20 +1,20 @@
complete -c perl -s 0 -d "Specify record separator"
complete -c perl -s a -d "Feed input to split"
complete -c perl -s c -d "Check syntax"
complete -c perl -s d -d "Debugger"
complete -c perl -s D -x -d "Debug option"
complete -c perl -s e -x -d "Execute command"
complete -c perl -s F -d "Set regexp used to split input"
complete -c perl -s i -d "Edit files in-place"
complete -c perl -s I -d "Include path"
complete -c perl -s l -d "Line ending processing"
complete -c perl -s n -d "Loop script"
complete -c perl -s p -d "Loop script, print $_"
complete -c perl -s P -d "Invoke CPP"
complete -c perl -s s -d "Define custom switches"
complete -c perl -s S -d "Search $PATH for script"
complete -c perl -s T -d "Taint checking"
complete -c perl -s U -d "Unsafe mode"
complete -c perl -s v -d "Display version"
complete -c perl -s x -d "Extract script"
complete -c perl -s 0 -d 'Specify record separator'
complete -c perl -s a -d 'Feed input to split'
complete -c perl -s c -d 'Check syntax'
complete -c perl -s d -d 'Debugger'
complete -c perl -s D -x -d 'Debug option'
complete -c perl -s e -x -d 'Execute command'
complete -c perl -s F -d 'Set regexp used to split input'
complete -c perl -s i -d 'Edit files in-place'
complete -c perl -s I -d 'Include path'
complete -c perl -s l -d 'Line ending processing'
complete -c perl -s n -d 'Loop script'
complete -c perl -s p -d 'Loop script, print $_'
complete -c perl -s P -d 'Invoke CPP'
complete -c perl -s s -d 'Define custom switches'
complete -c perl -s S -d 'Search $PATH for script'
complete -c perl -s T -d 'Taint checking'
complete -c perl -s U -d 'Unsafe mode'
complete -c perl -s v -d 'Display version'
complete -c perl -s x -d 'Extract script'

View File

@@ -122,7 +122,7 @@ complete $rpm_erase -l repackage -d 'Re-package the files before erasing'
complete $rpm_erase -l test -d 'Dont really uninstall anything, just go through the motions'
set -e rpm_erase
set -- rpm_mode -c rpm -n "__fish_contains_opt -s e -s i -s F -s V -s U -s q erase install freshen verify upgrade query; if test $status = 0; false; else; true; end"
set -- rpm_mode -c rpm -n '__fish_contains_opt -s e -s i -s F -s V -s U -s q erase install freshen verify upgrade query; if test $status = 0; false; else; true; end'
complete $rpm_mode -s i -l install -d 'Install new package'
complete $rpm_mode -s U -l upgrade -d 'Upgrade existing package'
complete $rpm_mode -s F -l freshen -d 'Upgrade package if already installed'

View File

@@ -1,25 +1,25 @@
#Completions for ruby
complete -c ruby -s 0 -d "Specify record separator"
complete -c ruby -s a -d "Feed input to split"
complete -c ruby -s c -d "Check syntax"
complete -c ruby -s K -d "Kanji code-set"
complete -c ruby -s d -l debug -d "Debugger"
complete -c ruby -s e -x -d "Execute command"
complete -c ruby -s h -l help -d "Display help"
complete -c ruby -s F -d "Set regexp used to split input"
complete -c ruby -s i -d "Edit files in-place"
complete -c ruby -s I -d "Include path"
complete -c ruby -s l -d "Line ending processing"
complete -c ruby -s n -d "Loop script"
complete -c ruby -s p -d "Loop script, print $_"
complete -c ruby -s r -r -d "Require file"
complete -c ruby -s s -d "Define custom switches"
complete -c ruby -s S -d "Search $PATH for script"
complete -c ruby -s T -d "Taint checking"
complete -c ruby -s v -l verbose -d "Verbose mode"
complete -c ruby -s w -d "Verbose mode without message"
complete -c ruby -l version -d "Display version"
complete -c ruby -s x -d "Extract script"
complete -c ruby -s X -x -a "(__fish_complete_directory (commandline -ct))" -d "Directory"
complete -c ruby -s y -l yydebug -d "Compiler debug mode"
complete -c ruby -s 0 -d 'Specify record separator'
complete -c ruby -s a -d 'Feed input to split'
complete -c ruby -s c -d 'Check syntax'
complete -c ruby -s K -d 'Kanji code-set'
complete -c ruby -s d -l debug -d 'Debugger'
complete -c ruby -s e -x -d 'Execute command'
complete -c ruby -s h -l help -d 'Display help'
complete -c ruby -s F -d 'Set regexp used to split input'
complete -c ruby -s i -d 'Edit files in-place'
complete -c ruby -s I -d 'Include path'
complete -c ruby -s l -d 'Line ending processing'
complete -c ruby -s n -d 'Loop script'
complete -c ruby -s p -d 'Loop script, print $_'
complete -c ruby -s r -r -d 'Require file'
complete -c ruby -s s -d 'Define custom switches'
complete -c ruby -s S -d 'Search $PATH for script'
complete -c ruby -s T -d 'Taint checking'
complete -c ruby -s v -l verbose -d 'Verbose mode'
complete -c ruby -s w -d 'Verbose mode without message'
complete -c ruby -l version -d 'Display version'
complete -c ruby -s x -d 'Extract script'
complete -c ruby -s X -x -a '(__fish_complete_directory (commandline -ct))' -d 'Directory'
complete -c ruby -s y -l yydebug -d 'Compiler debug mode'

View File

@@ -3,35 +3,35 @@ function __fish_complete_screen -d "Print a list of running screen sessions"
end
complete -c screen -x
complete -c screen -s a -d "Include all capabilitys"
complete -c screen -s A -d "Adapt window size"
complete -c screen -s c -r -d "Specify init file"
complete -c screen -s d -d "Detach screen" -a "(__fish_complete_screen)"
complete -c screen -s D -d "Detach screen" -a "(__fish_complete_screen)"
complete -c screen -s r -d "Reattach session" -a "(__fish_complete_screen)"
complete -c screen -s R -d "Reattach/create session"
complete -c screen -o RR -d "Reattach/create any session"
complete -c screen -s e -x -d "Escape character"
complete -c screen -s f -d "Flow control on"
complete -c screen -o fn -d "Flow control off"
complete -c screen -o fa -d "Flow control automatic"
complete -c screen -s h -x -d "History length"
complete -c screen -s i -d "Interrupt display on C-c"
complete -c screen -s l -d "Login on"
complete -c screen -o ln -d "Login off"
complete -c screen -o ls -d "List sessions"
complete -c screen -o list -d "List sessions"
complete -c screen -s L -d "Log on"
complete -c screen -s m -d "Ignore $STY"
complete -c screen -s O -d "Optimal output"
complete -c screen -s p -d "Preselect window"
complete -c screen -s q -d "Quiet mode"
complete -c screen -s s -r -d "Set shell"
complete -c screen -s S -x -d "Session name"
complete -c screen -s t -x -d "Session title"
complete -c screen -s U -d "UTF-8 mode"
complete -c screen -s v -d "Display version"
complete -c screen -o wipe -d "Wipe dead sessions"
complete -c screen -s x -d "Multi attach"
complete -c screen -s X -r -d "Send command"
complete -c screen -s a -d 'Include all capabilitys'
complete -c screen -s A -d 'Adapt window size'
complete -c screen -s c -r -d 'Specify init file'
complete -c screen -s d -d 'Detach screen' -a '(__fish_complete_screen)'
complete -c screen -s D -d 'Detach screen' -a '(__fish_complete_screen)'
complete -c screen -s r -d 'Reattach session' -a '(__fish_complete_screen)'
complete -c screen -s R -d 'Reattach/create session'
complete -c screen -o RR -d 'Reattach/create any session'
complete -c screen -s e -x -d 'Escape character'
complete -c screen -s f -d 'Flow control on'
complete -c screen -o fn -d 'Flow control off'
complete -c screen -o fa -d 'Flow control automatic'
complete -c screen -s h -x -d 'History length'
complete -c screen -s i -d 'Interrupt display on C-c'
complete -c screen -s l -d 'Login on'
complete -c screen -o ln -d 'Login off'
complete -c screen -o ls -d 'List sessions'
complete -c screen -o list -d 'List sessions'
complete -c screen -s L -d 'Log on'
complete -c screen -s m -d 'Ignore $STY'
complete -c screen -s O -d 'Optimal output'
complete -c screen -s p -d 'Preselect window'
complete -c screen -s q -d 'Quiet mode'
complete -c screen -s s -r -d 'Set shell'
complete -c screen -s S -x -d 'Session name'
complete -c screen -s t -x -d 'Session title'
complete -c screen -s U -d 'UTF-8 mode'
complete -c screen -s v -d 'Display version'
complete -c screen -o wipe -d 'Wipe dead sessions'
complete -c screen -s x -d 'Multi attach'
complete -c screen -s X -r -d 'Send command'

View File

@@ -16,19 +16,20 @@ set -g IFS \ \t\n
#
for i in /bin /usr/bin /usr/X11R6/bin @PREFIX@/bin
if test -d $i
if not echo $PATH|grep $i >/dev/null
if not expr "$PATH" : .\*$i.\* >/dev/null
if test -d $i
set PATH $PATH $i
end
end
end
#
# Set some value for LANG if nothing was set before
#
if status --is-login
if not count $LANG >/dev/null
if not set -q LANG >/dev/null
set -gx LANG en_US.UTF-8
end
end
@@ -39,13 +40,9 @@ end
# situation as well?
#
if count $LANG >/dev/null
if test (expr match $LANG ".*UTF") -gt 0
if count $TERM >/dev/null
if test linux = $TERM
unicode_start ^/dev/null
end
end
if expr match "$LANG" ".*UTF" >/dev/null
if test linux = "$TERM"
unicode_start ^/dev/null
end
end
@@ -56,7 +53,7 @@ end
#
for i in DISPLAY
if test (count $$i) -gt 1
if set -q $i
set -- $i (printf ":%s" $$i|cut -c 2-)
end
end

View File

@@ -42,10 +42,10 @@ function __fish_complete_suffix -d "Complete using files"
set -- desc $argv[3]
set -- base (echo $comp |sed -e 's/\.[a-zA-Z0-9]*$//')
eval "set -- files "$base"*"$suff
eval "set -- files $base*$suff"
if test $files[1]
printf "%s\t"$desc"\n" $files
printf "%s\t$desc\n" $files
end
#
@@ -74,7 +74,7 @@ function __fish_complete_directory -d "Complete using directories"
eval "set -- dirs "$comp"*/"
if test $dirs[1]
printf "%s\t"$desc"\n" $dirs
printf "%s\t$desc\n" $dirs
end
end

View File

@@ -6,10 +6,8 @@
function _contains_help -d "Helper function for contains"
set bullet \*
if count $LANG >/dev/null
if test (expr match $LANG ".*UTF") -gt 0
set bullet \u2022
end
if expr match "$LANG" ".*UTF" >/dev/null
set bullet \u2022
end
echo \tcontains - Test if a word is present in a list\n
@@ -222,11 +220,9 @@ function prompt_pwd -d "Print the current working directory, ellipsise it if it
if test $len -gt $max_width
#Write ellipsis character if known to be using UTF
#else use $
set -l ellipsis "$" #default
if count $LANG >/dev/null
if test (expr match $LANG ".*UTF") -gt 0
set ellipsis \u2026
end
set -l ellipsis '$' #default
if expr match "$LANG" ".*UTF" >/dev/null
set ellipsis \u2026
end
printf %s%s $ellipsis (echo $wd|cut -c (echo $len-$max_width-1|bc)- ^/dev/null )
else
@@ -564,10 +560,8 @@ end
function __fish_type_help -d "Help for the type shellscript function"
set bullet \*
if count $LANG >/dev/null
if test (expr match $LANG ".*UTF") -gt 0
set bullet \u2022
end
if expr match "$LANG" ".*UTF" >/dev/null
set bullet \u2022
end
echo \ttype - Indicate how a name would be interpreted if used as a \n\tcommand name

View File

@@ -58,7 +58,7 @@ function set_default_color -d "Set an universal variable, unless it has already
set -U -- $argv
return
end
if contains -- $$argv[1] (set_color --print-colors)
if contains -- $$argv[1] (set_color -c)
return
end
set -U -- $argv

View File

@@ -49,6 +49,7 @@ implementation in fish is as of yet incomplete.
#include "parser.h"
#include "env.h"
#include "expand.h"
#include "event.h"
static void input_read_inputrc( wchar_t *fn );
@@ -697,7 +698,7 @@ static wchar_t *input_expand_sequence( const wchar_t *in )
}
debug( 1, L"Invalid sequence - Control-nothing?\n" );
error = 1;
break;
}
@@ -1266,6 +1267,10 @@ static void add_vi_bindings()
*/
static int interrupt_handler()
{
/*
Fire any pending events
*/
event_fire( 0, 0 );
if( job_reap( 1 ) )
repaint();
if( reader_interupted() )

2
main.c
View File

@@ -111,7 +111,7 @@ int main( int argc, char **argv )
while( 1 )
{
#ifdef __GLIBC__
#ifdef HAVE_GETOPT_LONG
static struct option
long_options[] =
{

View File

@@ -1018,7 +1018,7 @@ int main (int argc, char *argv[])
*/
while( 1 )
{
#ifdef __GLIBC__
#ifdef HAVE_GETOPT_LONG
static struct option
long_options[] =
{

View File

@@ -1707,7 +1707,6 @@ static void eval_job( tokenizer *tok )
current_block->job = j;
proc_had_barrier=0;
if( is_interactive )
{
@@ -1763,7 +1762,15 @@ static void eval_job( tokenizer *tok )
if(!skip )
{
int was_builtin = 0;
// if( j->first_process->type==INTERNAL_BUILTIN && !j->first_process->next)
// was_builtin = 1;
exec( j );
/* Only external commands require a new fishd barrier */
if( !was_builtin )
proc_had_barrier=0;
}
else
{

View File

@@ -114,7 +114,7 @@ int main( int argc, char **argv )
while( 1 )
{
#ifdef __GLIBC__
#ifdef HAVE_GETOPT_LONG
static struct option
long_options[] =
{

View File

@@ -32,7 +32,7 @@ int main( int argc, char **argv )
while( 1 )
{
#ifdef __GLIBC__
#ifdef HAVE_GETOPT_LONG
static struct option
long_options[] =
{

View File

@@ -1,6 +1,8 @@
/** \file wildcard.c
My own globbing implementation. Needed to implement this to
support tab-expansion of globbed parameters.
Fish needs it's own globbing implementation to support
tab-expansion of globbed parameters. Also provides recursive
wildcards using **.
*/
@@ -25,6 +27,19 @@
#include "reader.h"
#include "expand.h"
/**
This flag is set in the flags parameter of wildcard_expand if the
call is part of a recursiv wildcard search. It is used to make sure
that the contents of subdirectories are only searched once.
*/
#define WILDCARD_RECURSIVE 64
/**
The maximum length of a filename token. This is a fallback value,
an attempt to find the true value using patchconf is always made.
*/
#define MAX_FILE_LENGTH 1024
int wildcard_has( const wchar_t *str, int internal )
{
wchar_t prev=0;
@@ -72,7 +87,9 @@ static int wildcard_match2( const wchar_t *str,
{
/* Ignore hidden file */
if( is_first && *str == L'.' )
{
return 0;
}
/* Try all submatches */
do
@@ -83,8 +100,16 @@ static int wildcard_match2( const wchar_t *str,
while( *(str++) != 0 );
return 0;
}
if( *wc == ANY_CHAR )
{
if( is_first && *str == L'.' )
{
return 0;
}
return wildcard_match2( str+1, wc+1, 0 );
}
if( *wc == *str )
return wildcard_match2( str+1, wc+1, 0 );
@@ -205,15 +230,13 @@ static wchar_t *make_path( const wchar_t *base_dir, const wchar_t *name )
int base_len = wcslen( base_dir );
if( !(long_name= malloc( sizeof(wchar_t)*(base_len+wcslen(name)+1) )))
{
return 0;
die_mem();
}
wcscpy( long_name, base_dir );
wcscpy(&long_name[base_len], name );
return long_name;
}
void get_desc( wchar_t *fn, string_buffer_t *sb, int is_cmd )
{
const wchar_t *desc;
@@ -282,6 +305,11 @@ void get_desc( wchar_t *fn, string_buffer_t *sb, int is_cmd )
}
}
/*
Test if the file specified by the given filename matches the
expantion flags specified. flags can be a combination of
EXECUTABLES_ONLY and DIRECTORIES_ONLY.
*/
static int test_flags( wchar_t *filename,
int flags )
{
@@ -306,11 +334,37 @@ int wildcard_expand( const wchar_t *wc,
int flags,
array_list_t *out )
{
/* Points to the end of the current wildcard segment */
wchar_t *wc_end;
/* Variables for traversing a directory */
struct dirent *next;
DIR *dir;
/* The result returned */
int res = 0;
/* Length of the directory to search in */
int base_len;
/* Variables for testing for presense of recursive wildcards */
wchar_t *wc_recursive;
int is_recursive;
/* Sligtly mangled version of base_dir */
const wchar_t *dir_string;
/* Description for completions */
string_buffer_t sb_desc;
// debug( 3, L"WILDCARD_EXPAND %ls in %ls", wc, base_dir );
if( flags & ACCEPT_INCOMPLETE )
{
/* Avoid excessive number of returned matches for wc ending with a * */
/*
Avoid excessive number of returned matches for wc ending with a *
*/
int len = wcslen(wc);
if( len && (wc[len-1]==ANY_STRING) )
{
@@ -321,50 +375,58 @@ int wildcard_expand( const wchar_t *wc,
return res;
}
}
struct dirent *next;
wchar_t *wc_end = wcschr(wc,L'/');
DIR *dir;
int res = 0;
int base_len = wcslen( base_dir );
wchar_t *wc_recursive = wcschr( wc, ANY_STRING_RECURSIVE );
int is_recursive = is_recursive = ( wc_recursive && (!wc_end || wc_recursive < wc_end));
/*
Initialize various variables
*/
const wchar_t *dir_string = base_dir[0]==L'\0'?L".":base_dir;
string_buffer_t sb_desc;
sb_init( &sb_desc );
// if( accept_incomplete )
// wprintf( L"Glob %ls in '%ls'\n", wc, base_dir );//[0]==L'\0'?L".":base_dir );
/*
Test for recursive match string in current segment
*/
dir_string = base_dir[0]==L'\0'?L".":base_dir;
if( !(dir = wopendir( dir_string )))
{
// if( errno != EACCES && errno != ENOENT )
// wperror( L"opendir" );
return 0;
}
/*
Is this segment of the wildcard the last?
*/
if( wc_end == 0 )
wc_end = wcschr(wc,L'/');
base_len = wcslen( base_dir );
/*
Test for recursive match string in current segment
*/
wc_recursive = wcschr( wc, ANY_STRING_RECURSIVE );
is_recursive = ( wc_recursive && (!wc_end || wc_recursive < wc_end));
/*
This makes sure that the base
directory of the recursive search is
also searched for matching files.
*/
if( is_recursive && (wc_end==(wc+1)) && !(flags & WILDCARD_RECURSIVE ) )
{
wildcard_expand( wc_end + 1,
base_dir,
flags,
out );
}
if( flags & ACCEPT_INCOMPLETE )
sb_init( &sb_desc );
/*
Is this segment of the wildcard the last?
*/
if( !wc_end && !is_recursive )
{
/*
Wildcard segment is the last segment
Wildcard segment is the last segment,
Insert all matching files/directories
*/
if( wc[0]=='\0' )
{
/*
The last wildcard segment is empty. Insert everything if completing, the directory itself otherwise.
The last wildcard segment is empty. Insert everything if
completing, the directory itself otherwise.
*/
if( flags & ACCEPT_INCOMPLETE )
{
@@ -375,20 +437,10 @@ int wildcard_expand( const wchar_t *wc,
wchar_t *name = str2wcs(next->d_name);
if( name == 0 )
{
/* closedir( dir );*/
/* return -1; */
continue;
}
wchar_t *long_name = make_path( base_dir, name );
if( long_name == 0 )
{
wperror( L"malloc" );
closedir( dir );
free(name);
return 0;
}
if( test_flags( long_name, flags ) )
{
get_desc( long_name,
@@ -407,7 +459,7 @@ int wildcard_expand( const wchar_t *wc,
else
{
res = 1;
al_push( out, wcsdup( base_dir ) );
al_push_check( out, wcsdup( base_dir ) );
}
}
else
@@ -423,22 +475,13 @@ int wildcard_expand( const wchar_t *wc,
continue;
}
/* wprintf( L"Filen heter %s\n\n\n", next->d_name );*/
/* wprintf( L"Match %ls (%s) against %ls\n\n\n", name, "tjo", wc );*/
if( flags & ACCEPT_INCOMPLETE )
{
/* wprintf( L"match %ls to %ls\n", name, wc );*/
wchar_t *long_name = make_path( base_dir, name );
if( long_name == 0 )
{
wperror( L"malloc" );
closedir( dir );
free(name);
return 0;
}
/*
Test for matches before stating file, so as to minimize the number of stat calls
Test for matches before stating file, so as to minimize the number of calls to the much slower stat function
*/
if( wildcard_complete( name,
wc,
@@ -446,8 +489,6 @@ int wildcard_expand( const wchar_t *wc,
0,
0 ) )
{
if( test_flags( long_name, flags ) )
{
get_desc( long_name,
@@ -470,15 +511,8 @@ int wildcard_expand( const wchar_t *wc,
if( wildcard_match2( name, wc, 1 ) )
{
wchar_t *long_name = make_path( base_dir, name );
if( long_name == 0 )
{
wperror( L"malloc" );
closedir( dir );
free(name);
return 0;
}
al_push( out, long_name );
al_push_check( out, long_name );
res = 1;
}
}
@@ -489,34 +523,52 @@ int wildcard_expand( const wchar_t *wc,
else
{
/*
Wilcard segment is not the last segment.
Recursively call wildcard_expand for all matching subdirectories.
Wilcard segment is not the last segment. Recursively call
wildcard_expand for all matching subdirectories.
*/
/*
wc_str is the part of the wildcarded string from the
beginning to the first slash
*/
wchar_t *wc_str;
/*
new_dir is a scratch area containing the full path to a
file/directory we are iterating over
*/
wchar_t *new_dir;
static size_t ln=1024;
/*
The maximum length of a file element
*/
static size_t ln=MAX_FILE_LENGTH;
char * narrow_dir_string = wcs2str( dir_string );
if( narrow_dir_string )
{
ln = pathconf( narrow_dir_string, _PC_NAME_MAX ); /* Find out how long the filename can be in a worst case scenario */
/*
Find out how long the filename can be in a worst case
scenario
*/
ln = pathconf( narrow_dir_string, _PC_NAME_MAX );
/*
If not specified, use som large number as fallback
*/
if( ln < 0 )
ln = 1024;
ln = MAX_FILE_LENGTH;
free( narrow_dir_string );
}
new_dir= malloc( sizeof(wchar_t)*(base_len+ln+2) );
wc_str = wcsndup(wc, wc_end-wc);
wc_str = wc_end?wcsndup(wc, wc_end-wc):wcsdup(wc);
if( (!new_dir) || (!wc_str) )
{
if( new_dir )
free( new_dir );
if( wc_str )
free( wc_str );
wperror( L"malloc" );
closedir( dir );
return 0;
die_mem();
}
wcscpy( new_dir, base_dir );
while( (next=readdir(dir))!=0 )
@@ -526,56 +578,103 @@ int wildcard_expand( const wchar_t *wc,
{
continue;
}
/*
Test if the file/directory name matches the whole
wildcard element, i.e. regular matching.
*/
int whole_match = wildcard_match2( name, wc_str, 1 );
int partial_match = 0;
if( wildcard_match2( name, wc_str, 1 ) )
/*
If we are doing recursive matching, also check if this
directory matches the part up to the recusrive
wildcard, if so, then we can search all subdirectories
for matches.
*/
if( is_recursive )
{
wchar_t *end = wcschr( wc, ANY_STRING_RECURSIVE );
wchar_t *wc_sub = wcsndup( wc, end-wc+1);
partial_match = wildcard_match2( name, wc_sub, 1 );
free( wc_sub );
}
if( whole_match || partial_match )
{
int new_len;
struct stat buf;
wcscpy(&new_dir[base_len], name );
free(name);
char *dir_str = wcs2str( new_dir );
char *dir_str;
int stat_res;
if( !dir_str )
{
continue;
}
stat_res= stat( dir_str, &buf );
free( dir_str );
if( stat_res )
{
continue;
}
if( buf.st_mode & S_IFDIR )
wcscpy(&new_dir[base_len], name );
dir_str = wcs2str( new_dir );
if( dir_str )
{
new_len = wcslen( new_dir );
new_dir[new_len] = L'/';
new_dir[new_len+1] = L'\0';
switch( wildcard_expand( wc_end + 1, new_dir, flags, out ) )
stat_res = stat( dir_str, &buf );
free( dir_str );
if( !stat_res )
{
case 0:
break;
case 1:
res = 1;
break;
if( buf.st_mode & S_IFDIR )
{
new_len = wcslen( new_dir );
new_dir[new_len] = L'/';
new_dir[new_len+1] = L'\0';
/*
Regular matching
*/
if( whole_match )
{
res |= wildcard_expand( wc_end?wc_end + 1:L"",
new_dir,
flags,
out );
}
/*
Recursive matching
*/
if( partial_match )
{
res |= wildcard_expand( wcschr( wc, ANY_STRING_RECURSIVE ),
new_dir,
flags | WILDCARD_RECURSIVE,
out );
}
}
}
}
}
}
else
{
free(name);
}
free(name);
}
free( wc_str );
free( new_dir );
}
closedir( dir );
sb_destroy( &sb_desc );
if( flags & ACCEPT_INCOMPLETE )
sb_destroy( &sb_desc );
return res;
}
void al_push_check( array_list_t *l, const wchar_t *new )
{
int i;
for( i = 0; i < al_get_count(l); i++ )
{
if( !wcscmp( al_get(l, i), new ) )
{
free( new );
return;
}
}
al_push( l, new );
}

View File

@@ -93,4 +93,10 @@ int wildcard_complete( const wchar_t *str,
const wchar_t *(*desc_func)(const wchar_t *),
array_list_t *out );
/**
Push string if not already in list
*/
void al_push_check( array_list_t *l, const wchar_t *str );
#endif