🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Chip Salzenberg Mon, 05 Feb 1990 18:23
Batch 1.04 patch: "`command`" whitespace
#1144
Author: Chip Salzenberg
Date: Mon, 05 Feb 1990 18:23
54 lines
1958 bytes
As distributed, Bash 1.04 fails to distinguish between "`cmd`" and
`cmd`.  In particular, the quoted form is supposed to preserve all
whitespace output by the command, except for a final newline, which
should be stripped.  The below patch fixes this bug.

Index: subst.c
***************
*** 1053,1058 ****
  					istring_size += DEFAULT_ARRAY_SIZE);
  
! 		  if (whitespace  (c) || c == '\n')
  		    {
  		      if (!whitespace (lastc) && lastc != '\n')
  			istring[istring_index++] = ' ';
--- 1053,1062 ----
  					istring_size += DEFAULT_ARRAY_SIZE);
  
! 		  if (quoted)
  		    {
+ 		      istring[istring_index++] = c | 0x80;
+ 		    }
+ 		  else if (whitespace (c) || c == '\n')
+ 		    {
  		      if (!whitespace (lastc) && lastc != '\n')
  			istring[istring_index++] = ' ';
***************
*** 1073,1079 ****
  		free (temp);
  
! 	      strip_leading (istring + start_index);
! 	      strip_trailing (istring + start_index);
! 	      istring_index = strlen (istring);
  	      goto next_character;
  	    }
--- 1077,1092 ----
  		free (temp);
  
! 	      if (quoted)
! 	      {
! 		if (istring_index > 0 &&
! 		    (istring[istring_index - 1] & 0x7F) == '\n')
! 		  istring[--istring_index] = '\0';
! 	      }
! 	      else
! 	      {
! 		strip_leading (istring + start_index);
! 		strip_trailing (istring + start_index);
! 		istring_index = strlen (istring);
! 	      }
  	      goto next_character;
  	    }

-- 
Chip Salzenberg at ComDev/TCT   <chip%tct@ateng.com>, <uunet!ateng!tct!chip>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads