W3C home > Mailing lists > Public > xproc-dev@w3.org > January 2012

RE: why not in p:exec ... ""If cwd is not specified, the cwd is the same as the xproc file one is running."?

From: David Lee <dlee@calldei.com>
Date: Wed, 18 Jan 2012 07:14:08 -0500
To: "'Norman Walsh'" <ndw@nwalsh.com>, "'XProc Dev'" <xproc-dev@w3.org>
Message-ID: <00de01ccd5da$aee19d30$0ca4d790$@calldei.com>
Good points norm.
To add one more.  Let us not forget the decades of historical precidence
learned by the 'school of hard knocks' .    Very often its more useful (and
more secure)
for the "CWD" of sub-procs in systems that support a CWD to be that of the
calling environment, NOT that of the script. 
Example, suppose you put a script in /usr/scripts/coolscript.xproc

that runs through all *.xml files *in your current directory* ...
The intent is it works on the CWD of the caller not where the script is
located.
This keeps a good issolation of code and data. "as it should be".

Of course there are use case where this is not ideal ... but over the
decades this pattern has been found to be "a good thing"


----------------------------------------
David A. Lee
dlee@calldei.com
http://www.xmlsh.org

-----Original Message-----
From: Norman Walsh [mailto:ndw@nwalsh.com] 
Sent: Wednesday, January 18, 2012 7:01 AM
To: XProc Dev
Subject: Re: why not in p:exec ... ""If cwd is not specified, the cwd is the
same as the xproc file one is running."?

Alex Muir <alex.g.muir@gmail.com> writes:
> Thanks for the simpler way and the explanation, although other steps
> seem to rely on a concept of cwd being the directory the xproc file
> is in for example xslt files are referenced as relative to the
> location of the xproc file so I'm not clear on the reasons p:exec
> would differ from those and a bit interested to know why as I assume
> there is a reason.

Most XML tools resolve links relative to the base URI of some element.
That's the way that href links in XProc and XSLT files work, for example.
Those steps can fail if there is no base URI.

The spec could have said that the CWD for p:exec should be the same
directory as the directory that contains the XProc pipeline document,
except:

1. What about pipelines that are accessed by http?
2. What about pipelines that arrive on stdin?
3. What about operating environments that have no concept of a CWD?

The spec could have said "should" I suppose with caveats.

But there's also the question of whether or not that's the right thing.

The build script for my XProc book uses p:exec and relies on the fact
that "bin/perlscript.pl" will do the right thing. I could have written
it so that "../bin/perlscript.pl" would do the right thing, of course,
but then perlscript.pl has to be changed to look in ".." for config files
and such, at least potentially.

The p:exec step has a cwd option; you can certainly write your own pipeline
library that contains my:exec that does the exact same thing as p:exec
except
it sets the cwd option appropriately.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
Lead Engineer
MarkLogic Corporation
Phone: +1 413 624 6676
www.marklogic.com
Received on Wednesday, 18 January 2012 12:14:43 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 18 January 2012 12:14:43 GMT