🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #1147

Bash 1.04 patch: trailing ":" in PATH

#1147
From: Chip Salzenberg
Date: Tue, 06 Feb 1990 17:38
49 lines
1742 bytes
Bash 1.04 correctly interprets a PATH of ":/bin:/usr/bin" to mean
"search the currect directory first."  However, it does not correctly
interpret "/bin:/usr/bin:" which is supposed to mean "search the
current directory last."  This patch fixes the bug.

Note that this bug affects CDPATH as well, and this patch fixes it too.

Index: execute_cmd.c
***************
*** 1537,1547 ****
    int i, start;
  
!   i = start = *index;
!   if ((i >= strlen (string)) || !string) return ((char *)NULL);
  
!   while (string[i] && string[i] != ':') i++;
    if (i == start) {
-     if (!string[i]) return ((char *)NULL);
-     (*index)++;
      return (savestring (""));
    } else {
--- 1537,1551 ----
    int i, start;
  
!   i = *index;
!   if ((i >= strlen (string)) || !string)
!     return ((char *)NULL);
  
!   if (string[i] == ':')
!     i++;
!   start = i;
!   while (string[i] && string[i] != ':')
!     i++;
!   *index = i;
    if (i == start) {
      return (savestring (""));
    } else {
***************
*** 1549,1554 ****
      strncpy (value, &string[start], (i - start));
      value [i - start] = '\0';
-     if (string[i]) ++i;
-     *index = i;
      return (value);
    }
--- 1553,1556 ----

-- 
Chip Salzenberg at ComDev/TCT   <chip%tct@ateng.com>, <uunet!ateng!tct!chip>
Technical Details
Message-ID: <9002061238.AA13422@tct.uucp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!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!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!tct!chip
From: tct!chip@UUNET.UU.NET (Chip Salzenberg)
Newsgroups: gnu.bash.bug
Subject: Bash 1.04 patch: trailing ":" in PATH
Message-ID: <9002061238.AA13422@tct.uucp>
Date: 6 Feb 90 17:38:35 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 49