[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ast-users
Subject:    [ast-users] Bug with here strings? (ksh93o)
From:       dgk () research ! att ! com (David Korn)
Date:       2004-09-01 22:50:02
Message-ID: 200409020250.WAA75250 () raptor ! research ! att ! com
[Download RAW message or body]


> I have observed some strange behaviour with "here strings"...
> 
> It seems that the double quotes surrounding the here string argument
> are passed to the command (dc) if variables are expanded (see Case 2,
> where dc reports an error). If no variables are expanded (Case 3 and 4)
> everything is fine. The result is also correct if there are no quotes
> surrounding the here string argument (Case 1).
Yes, this behavior is strange and here is why.  I am adding this to
my bug list for a future release.  The problem is that ksh
treats
	dc <<< "${z}P"
as
	dc << !
	"${z}P"
	!
and since double quotes are not special inside here-documents they
are not stripped.  However, for
	dc <<< "101P"
the double quotes are stripped before constructing the here-document
so the double quotes are lost.  There are two possible solutions:
1.	always preserve the double quotes happens with here-documents.
	That would change your case 4.
2.	In this case treat the here document specially so that double
	quotes are quoting characters rather than literals.
	That would change your case 2.
> 
> I think this behaviour is inconsistent, at least surprising; variables
> within double quotes should be expanded and the quotes removed before
> the argument is passed to the command, IMO.
> 
> Regards,
> Janis
> 
> --BEGIN----------------------------------------
> 
> $ Version M 1993-12-28 o
> $ typeset -i z=101
> 
> $ # Case 1 - correct output
> $ dc <<< ${z}P
> Output:
> e
> 
> $ # Case 2 - surprising behaviour
> $ dc <<< "${z}P"
> Error:
> dc: '"' (042) unimplemented
> dc: e'"' (042) unimplemented
> 
> $ # Case 3 - correct output
> $ dc <<< 101P
> Output:
> e
> 
> $ # Case 4 - correct output
> $ dc <<< "101P"
> Output:
> e
> 
> --END------------------------------------------
> 
> _______________________________________________
> ast-users mailing list
> ast-users@research.att.com
> https://mailman.research.att.com/mailman/listinfo/ast-users
> 

David Korn
dgk@research.att.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic