diff options
-rw-r--r-- | etc/config.fish.in | 6 | ||||
-rw-r--r-- | exec.c | 66 | ||||
-rw-r--r-- | share/config.fish.in | 6 |
3 files changed, 46 insertions, 32 deletions
diff --git a/etc/config.fish.in b/etc/config.fish.in index 648fcac9..7940a402 100644 --- a/etc/config.fish.in +++ b/etc/config.fish.in @@ -4,12 +4,6 @@ # @configure_input@ # -# Set default field separators -# - -set -g IFS \ \t\n - -# # Some things should only be done for login terminals # @@ -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 1071a851..681c9099 100644 --- a/share/config.fish.in +++ b/share/config.fish.in @@ -6,6 +6,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 # |