mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 21:18:53 +00:00
Add support for changing token separator in command substitution. IT is not the first character of IFS, same as in various other shells
darcs-hash:20070422184956-ac50b-7e03b375feb9fd22e11aa7a7d8f8add8e3b717a5.gz
This commit is contained in:
parent
176c1a487b
commit
c323fc226f
3 changed files with 46 additions and 32 deletions
|
@ -3,12 +3,6 @@
|
|||
#
|
||||
# @configure_input@
|
||||
|
||||
#
|
||||
# Set default field separators
|
||||
#
|
||||
|
||||
set -g IFS \ \t\n
|
||||
|
||||
#
|
||||
# Some things should only be done for login terminals
|
||||
#
|
||||
|
|
66
exec.c
66
exec.c
|
@ -1501,9 +1501,27 @@ int exec_subshell( const wchar_t *cmd,
|
|||
int prev_subshell = is_subshell;
|
||||
int status, prev_status;
|
||||
io_data_t *io_buffer;
|
||||
|
||||
const wchar_t *ifs;
|
||||
char sep=0;
|
||||
|
||||
CHECK( cmd, -1 );
|
||||
|
||||
ifs = env_get(L"IFS");
|
||||
|
||||
if( ifs && ifs[0] )
|
||||
{
|
||||
if( ifs[0] < 128 )
|
||||
{
|
||||
sep = '\n';//ifs[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
sep = 0;
|
||||
debug( 0, L"Warning - invalid command substitution separator '%lc'. Please change the firsta character of IFS", ifs[0] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
is_subshell=1;
|
||||
io_buffer= io_buffer_create( 0 );
|
||||
|
||||
|
@ -1532,31 +1550,11 @@ int exec_subshell( const wchar_t *cmd,
|
|||
{
|
||||
while( 1 )
|
||||
{
|
||||
switch( *end )
|
||||
if( *end == 0 )
|
||||
{
|
||||
case 0:
|
||||
|
||||
if( begin != end )
|
||||
{
|
||||
wchar_t *el = str2wcs( begin );
|
||||
if( el )
|
||||
{
|
||||
al_push( lst, el );
|
||||
}
|
||||
else
|
||||
{
|
||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||
}
|
||||
}
|
||||
io_buffer_destroy( io_buffer );
|
||||
|
||||
return status;
|
||||
|
||||
case '\n':
|
||||
if( begin != end )
|
||||
{
|
||||
wchar_t *el;
|
||||
*end=0;
|
||||
el = str2wcs( begin );
|
||||
wchar_t *el = str2wcs( begin );
|
||||
if( el )
|
||||
{
|
||||
al_push( lst, el );
|
||||
|
@ -1565,9 +1563,25 @@ int exec_subshell( const wchar_t *cmd,
|
|||
{
|
||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||
}
|
||||
begin = end+1;
|
||||
break;
|
||||
}
|
||||
io_buffer_destroy( io_buffer );
|
||||
|
||||
return status;
|
||||
}
|
||||
else if( *end == sep )
|
||||
{
|
||||
wchar_t *el;
|
||||
*end=0;
|
||||
el = str2wcs( begin );
|
||||
if( el )
|
||||
{
|
||||
al_push( lst, el );
|
||||
}
|
||||
else
|
||||
{
|
||||
debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ );
|
||||
}
|
||||
begin = end+1;
|
||||
}
|
||||
end++;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
#
|
||||
# @configure_input@
|
||||
|
||||
#
|
||||
# Set default field separators
|
||||
#
|
||||
|
||||
set -g IFS \n\ \t
|
||||
|
||||
#
|
||||
# Set default search paths for completions and shellscript functions
|
||||
# unless they already exist
|
||||
|
|
Loading…
Reference in a new issue