diff --git a/etc/config.fish.in b/etc/config.fish.in index 648fcac91..7940a402d 100644 --- a/etc/config.fish.in +++ b/etc/config.fish.in @@ -3,12 +3,6 @@ # # @configure_input@ -# -# Set default field separators -# - -set -g IFS \ \t\n - # # Some things should only be done for login terminals # diff --git a/exec.c b/exec.c index 72826243c..d42df8089 100644 --- a/exec.c +++ b/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++; } diff --git a/share/config.fish.in b/share/config.fish.in index 1071a851d..681c90993 100644 --- a/share/config.fish.in +++ b/share/config.fish.in @@ -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