delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/28/13:50:30

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Dave Korn" <dk AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: "which" command does not expand "~" in path (base-files update needed)
Date: Tue, 28 Sep 2004 18:49:44 +0100
MIME-Version: 1.0
In-Reply-To: <NUTMEGCtgx8VUkRacUt0000013f@NUTMEG.CAM.ARTIMI.COM>
Message-ID: <NUTMEGyMp69YDqSkcJs00000140@NUTMEG.CAM.ARTIMI.COM>
X-OriginalArrivalTime: 28 Sep 2004 17:50:04.0923 (UTC) FILETIME=[960204B0:01C4A583]

> -----Original Message-----
> From: cygwin-owner On Behalf Of Dave Korn
> Sent: 28 September 2004 18:35

>   Why isn't it expanded by bash's tilde substitution at the 
> time the 'export'
> command line is parsed then?  That's sooo wrong.  Oh wow.  
> Guess what: it depends
> whether the *other* part of the assignment is quoted or not:

  Interesting.  From "info bash", node: "Shell Parameters":

"   A variable may be assigned to by a statement of the form
     NAME=[VALUE]

If VALUE is not given, the variable is assigned the null string.  All
VALUEs undergo tilde expansion, parameter and variable expansion,
command substitution, arithmetic expansion, and quote removal [ ... ]"

  And from node "Tilde Expansion":

"  If a word begins with an unquoted tilde character (`~'), all of the
characters up to the first unquoted slash (or all characters, if there
is no unquoted slash) are considered a TILDE-PREFIX.  If none of the
characters in the tilde-prefix are quoted, the characters in the
tilde-prefix following the tilde are treated as a possible LOGIN NAME. "

  So, given that words are separated by metachars, then the first word in the
NAME=VALUE construct 

        export FOO=~/bin:"${PATH}"

is the full string

        ~/bin:"${PATH}"

and therefore the presence of quotes later in the char shouldn't prevent bash
parsing the beginning of the word from the unquoted tilde char to the unquoted
slash immediately following it as a tilde-prefix, none of the chars in which are
quoted.

  Wonder if this is a real bug then, or if I've misread the shell parsing rules?
They are a bit ridiculously complicated and full of exceptions and special
cases.....

    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019