Welcome to iraf.net Friday, April 19 2024 @ 01:50 AM GMT


 Forum Index > Help Desk > General IRAF New Topic Post Reply
 Double slashes cancel out in Iraf path
   
ncaon
 09/26/2008 04:24PM (Read 3059 times)  
++---
Junior

Status: offline


Registered: 10/30/2005
Posts: 29
Hi,I've just noticed that when a string used as a path contains two adjacent slashes, they cancel out. The following example will make it clear:[code:1:92230909ba]
ecl> s1="/1/2/3/4/"
ecl> path(s1)
dhcp-dyn-55-44.a!/1/2/3/4/
ecl> s1="/1/2//3/4/"
ecl> path(s1)
dhcp-dyn-55-44.a!/1/23/4/
[/code:1:92230909ba]More in general, it seems that this is true for an even number of repeated slashes, while an odd number will leave just one slash in the path. I checked this in v2.12.2a and v2.14 (Linux) and v2.14 MacIntel.It's not that I define variables with extra slashes for fun; I was building a path string by appending to a Unix environment variable read using the envget command, something like:
[code:1:92230909ba]s1=envget("MYPATH")//"/some/subdirectory/"[/code:1:92230909ba]
with MYPATH already containing a trailing slash.I'm not sure whether this is a feature of Iraf, and it's there for very good reasons, or is some sort of parser bug. As far as I know, in Linux/Unix extra slashes are silently ignored and thus completely harmless. Thanks very much,
Nicola

 
Profile Email
 Quote
fitz
 09/26/2008 04:24PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Nicola,It;s not a bug in the sense that the task is doing what it says it will, even if that's not what you expect 8-) Specifically, the argument to PATHNAMES is a template string in which you're allowed to use wildcards and other metacharacters to expand the template. In this case the '//' is being interpreted as the string-concatenation operator in the template.One workaround for this in a script is to simply remove the duplicate, e.g.[code:1:87ff3feba2]
s1 = "/1/2//3/4/"
prinit (s1) | tr ("STDIN", "//", "/", collapse+)
[/code:1:87ff3feba2]If you know the envget returns a path with a trailing '/' you can also just leave it out of your string when you build the directory string. Cheers,
-Mike

 
Profile Email
 Quote
ncaon
 09/26/2008 04:24PM  
++---
Junior

Status: offline


Registered: 10/30/2005
Posts: 29
Hi Mike,thanks a lot for the very clear explanation. Of course the double slash is the concatenation operator, I wonder why I did not think of it myself.It took me some head scratching though, before I realized that all those "no files found" where due to the double slash in the path string.Cheers,
Nicola

 
Profile Email
 Quote
   
Content generated in: 0.09 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 
dog allergies remedies cialis 20 mg chilblain remedies


Privacy Policy
Terms of Use

User Functions

Login