aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2007-04-23 04:49:56 +1000
committerGravatar axel <axel@liljencrantz.se>2007-04-23 04:49:56 +1000
commitc323fc226f4d562b70b79c74f788b70648fdae41 (patch)
treece0aa7b5cb9b060f0c4806490370687ce95cdff9
parent176c1a487b89d4450be47f921034571233ab1740 (diff)
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
-rw-r--r--etc/config.fish.in6
-rw-r--r--exec.c66
-rw-r--r--share/config.fish.in6
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
#
diff --git a/exec.c b/exec.c
index 72826243..d42df808 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 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
#