🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #1144

Batch 1.04 patch: "`command`" whitespace

#1144
From: 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>
Technical Details
Message-ID: <9002051323.AA09758@tct.uucp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!UUNET.UU.NET!tct!chip

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!UUNET.UU.NET!tct!chip
From: tct!chip@UUNET.UU.NET (Chip Salzenberg)
Newsgroups: gnu.bash.bug
Subject: Batch 1.04 patch: "`command`" whitespace
Message-ID: <9002051323.AA09758@tct.uucp>
Date: 5 Feb 90 18:23:50 GMT
Sender: romig@tut.cis.ohio-state.edu
Distribution: gnu
Organization: Gnus Not Usenet
Lines: 54