NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/39195: /bin/sh tilde expansion doesn't take place on 'export=~/foo'



The following reply was made to PR bin/39195; it has been noted by GNATS.

From: "Greg A. Woods; Planix, Inc." <woods%planix.ca@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/39195: /bin/sh tilde expansion doesn't take place on 
'export=~/foo'
Date: Wed, 23 Jul 2008 12:33:51 -0400

 On 22-Jul-08, at 10:10 PM, jschauma%netmeister.org@localhost wrote:
 
 >> Number:         39195
 >> Category:       bin
 >> Synopsis:       /bin/sh tilde expansion doesn't take place on  
 >> 'export=~/foo'
 >> Confidential:   no
 >> Severity:       non-critical
 >> Priority:       low
 >> Responsible:    bin-bug-people
 >> State:          open
 >> Class:          sw-bug
 >> Submitter-Id:   net
 >> Arrival-Date:   Wed Jul 23 02:10:00 +0000 2008
 >> Originator:     Jan Schaumann
 >> Release:        NetBSD 4.0
 >> Organization:
 >      
 >> Environment:
 >      
 >      
 > System: NetBSD panix.netmeister.org 4.0 NetBSD 4.0 (PANIX-VC) #1:  
 > Sat Dec 22 22:16:02 EST 2007 
 > root%juggler.panix.com@localhost:/misc2/obj/misc2/ 
 > devel/netbsd/4.0/src/sys/arch/i386/compile/PANIX-VC i386
 > Architecture: i386
 > Machine: i386
 >> Description:
 >
 > See http://mail-index.netbsd.org/tech-userlevel/2008/07/14/msg000879.html
 >
 > On 14-Jul-08, at 3:00 PM, Jan Schaumann wrote:
 >>
 >> When exactly does /bin/sh's tilde expansion take place?
 >>
 >> $ /bin/sh -x
 >> $ export DIR=~/tmp
 >> + export DIR=~/tmp
 >> $ ls -ld $DIR
 >> + ls -ld ~/tmp
 >> ls: ~/tmp: No such file or directory
 >> $ cd
 >> + cd
 >> $ ls -ld tmp
 >> + ls -ld tmp
 >> drwx------  2 jschauma  users  512 Jul  4 21:37 tmp
 >> $ ^D
 >
 > Greg Woods noted:
 >
 > It works fine if the variable is set first without the "export":
 >
 >        15:14 [1] $ /bin/sh
 >      $ foobar=~/tmp
 >      $ echo $foobar
 >      /home/most/woods/tmp
 >      $ export foobar
 >      $ echo $foobar
 >      /home/most/woods/tmp
 >      $ ^D15:15 [2] $
 
 
 I also noted:
 
        HOWEVER, from my cursory reading of the Single UNIX Specification it  
 would seem that /bin/sh is conforming as-is -- i.e. the tilde  
 character is only to be recognized and expanded if it is an unquoted  
 character at the beginning of a word (except in an assignment where  
 multiple tilde-prefixes can be used with subsequent ones recognized  
 after any unquoted colon character).
 
 Further reading of SuS shows that the "assignment-like" behaviour of  
 "export" is defined, though perhaps somewhat poorly.  In the  
 informative text section the following text appears:
 
        IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/6 is applied, adding  
 the following text to the end of the first paragraph of the  
 DESCRIPTION: ``If the name of a variable is followed by = word, then  
 the value of that variable shall be set to word.''. The reason for  
 this change is that the SYNOPSIS for export includes:
 
        export name[=word]...
 
        but the meaning of the optional ``= word'' is never explained in the  
 text.
 
 So, I'm still somewhat confused (it appears this meaning kind of snuck  
 in by accident).
 
 In any case the use of "word" here suggests that during expansion a  
 tilde should be recognized and expanded if it appears un-quoted at the  
 beginning of "word".
 
 -- 
                                        Greg A. Woods; Planix, Inc.
                                        <woods%planix.ca@localhost>
 


Home | Main Index | Thread Index | Old Index