Re: [Chicken-hackers] [PATCH] Fix #1079 by ripping out pathname expansion and putting it into an egg [Was: Re: [PATCH] add pathname-expand]

2014-07-07 Thread Jim Ursetto
Thanks Peter!
Does this egg work with older Chicken versions? I.e. can I safely replace 
##sys#expand-home-path in sql-de-lite with pathname-expand across the board?
Jim

 On Jun 22, 2014, at 6:43, Peter Bex peter@xs4all.nl wrote:
 
 On Wed, Nov 13, 2013 at 01:05:55PM +, Mario Domenech Goulart wrote:
 Hi Felix and all,
 
 Getting rid of [pathname expansion] is the simplest approach.
 There are other ones, though.  Here are some of them:
 
 * move pathname-expand to an egg.  From users standpoint, I think it
  won't make a big difference between having pathname-expand in the core
  or in an egg.  It's something new anyway.  Having it as an egg can
  actually be a win in the end: it would be available to older chickens
  (although it wouldn't do anything, since pathname expansion is
  implicit).  But at least applications wouldn't break on an Unbound
  variable: pathname-expand error.  If pathname-expand is in the core,
  programs that use it will have a hard dependency on CHICKEN 4.9.0.
 
 I have now implemented Felix's pathname-expand patch as an egg (see
 http://wiki.call-cc.org/eggref/4/pathname-expand).  I've made a few small
 modifications:
 
 - The strings ~ and ~~ are also expanded, as are strings with a
   prefix of ~/ and ~~/ (but NOT ~~foo, and ~foo has the
   existing meaning of expanding too user foo's homedir)
 - The homedir is determined whenever it's required.  This allows
   privilege dropping and user switching to work correctly,
   in that the actual user id determines which homedir you get.
 - In case no user is found, we still raise an error, but I've added
   a specific exception subtype so that it can be caught more easily.
 - In case the repository path is undefined (can this be?), we raise
   an exception instead of using the current directory.
 
 I think we don't need to detect when it's running in an older CHICKEN,
 because in most situations when directories are expanded multiple times,
 they will be identical to the strings you get after only one expansion.
 By not stubbing out the procedures with no-ops, we nail down the
 behaviour more exactly, even in older CHICKENs.
 
 It's an egg, so if you disagree on the specifics, feel free to fix it
 and tag a new release.
 
 Attached is an updated version of Florian's patch to remove all implicit
 expansion from CHICKEN core.
 
 Cheers,
 Peter
 -- 
 http://www.more-magic.net
 0001-Remove-sys-expand-home-path-as-shell-expansion-has-n.patch
 ___
 Chicken-hackers mailing list
 Chicken-hackers@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-hackers

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] [PATCH] Fix #1079 by ripping out pathname expansion and putting it into an egg [Was: Re: [PATCH] add pathname-expand]

2014-07-07 Thread Peter Bex
On Mon, Jul 07, 2014 at 11:43:20AM -0500, Jim Ursetto wrote:
 Thanks Peter!
 Does this egg work with older Chicken versions? I.e. can I safely replace 
 ##sys#expand-home-path in sql-de-lite with pathname-expand across the board?
 Jim

That should work just fine.

Because the algorithm is slightly different, results may vary a bit,
but for 99% of the cases, they will be identical.  Of course, if you're
relying on $FOO environment variable substitution, you'd have to roll
your own replacement, because the egg (currently) does not do that at
all.  If enough people demand this, it could be added to the egg as an
optional feature.

Cheers,
Peter
-- 
http://www.more-magic.net

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] [PATCH] Fix #1079 by ripping out pathname expansion and putting it into an egg [Was: Re: [PATCH] add pathname-expand]

2014-07-07 Thread Jim Ursetto
Sounds good, I only use the tilde expansion, and that responsibility could 
probably even be removed and given to the caller. In my opinion the $FOO 
expansion can be jettisoned completely.
Jim

 On Jul 7, 2014, at 11:58, Peter Bex peter@xs4all.nl wrote:
 
 On Mon, Jul 07, 2014 at 11:43:20AM -0500, Jim Ursetto wrote:
 Thanks Peter!
 Does this egg work with older Chicken versions? I.e. can I safely replace 
 ##sys#expand-home-path in sql-de-lite with pathname-expand across the board?
 Jim
 
 That should work just fine.
 
 Because the algorithm is slightly different, results may vary a bit,
 but for 99% of the cases, they will be identical.  Of course, if you're
 relying on $FOO environment variable substitution, you'd have to roll
 your own replacement, because the egg (currently) does not do that at
 all.  If enough people demand this, it could be added to the egg as an
 optional feature.
 
 Cheers,
 Peter
 -- 
 http://www.more-magic.net

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] [PATCH] Fix #1079 by ripping out pathname expansion and putting it into an egg [Was: Re: [PATCH] add pathname-expand]

2014-07-01 Thread Evan Hanson
On 2014-06-22 13:43, Peter Bex wrote:
 I have now implemented Felix's pathname-expand patch as an egg (see
 http://wiki.call-cc.org/eggref/4/pathname-expand).
 
 [...]
 
 Attached is an updated version of Florian's patch to remove all implicit
 expansion from CHICKEN core.

Pushed, thank you Peter and Florian.

Evan

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


[Chicken-hackers] [PATCH] Fix #1079 by ripping out pathname expansion and putting it into an egg [Was: Re: [PATCH] add pathname-expand]

2014-06-22 Thread Peter Bex
On Wed, Nov 13, 2013 at 01:05:55PM +, Mario Domenech Goulart wrote:
 Hi Felix and all,
 
 Getting rid of [pathname expansion] is the simplest approach.
 There are other ones, though.  Here are some of them:
 
 * move pathname-expand to an egg.  From users standpoint, I think it
   won't make a big difference between having pathname-expand in the core
   or in an egg.  It's something new anyway.  Having it as an egg can
   actually be a win in the end: it would be available to older chickens
   (although it wouldn't do anything, since pathname expansion is
   implicit).  But at least applications wouldn't break on an Unbound
   variable: pathname-expand error.  If pathname-expand is in the core,
   programs that use it will have a hard dependency on CHICKEN 4.9.0.

I have now implemented Felix's pathname-expand patch as an egg (see
http://wiki.call-cc.org/eggref/4/pathname-expand).  I've made a few small
modifications:

- The strings ~ and ~~ are also expanded, as are strings with a
   prefix of ~/ and ~~/ (but NOT ~~foo, and ~foo has the
   existing meaning of expanding too user foo's homedir)
- The homedir is determined whenever it's required.  This allows
   privilege dropping and user switching to work correctly,
   in that the actual user id determines which homedir you get.
- In case no user is found, we still raise an error, but I've added
   a specific exception subtype so that it can be caught more easily.
- In case the repository path is undefined (can this be?), we raise
   an exception instead of using the current directory.

I think we don't need to detect when it's running in an older CHICKEN,
because in most situations when directories are expanded multiple times,
they will be identical to the strings you get after only one expansion.
By not stubbing out the procedures with no-ops, we nail down the
behaviour more exactly, even in older CHICKENs.

It's an egg, so if you disagree on the specifics, feel free to fix it
and tag a new release.

Attached is an updated version of Florian's patch to remove all implicit
expansion from CHICKEN core.

Cheers,
Peter
-- 
http://www.more-magic.net
From 4aff832727dc554c157b190f27cf7399589ba1e1 Mon Sep 17 00:00:00 2001
From: Peter Bex peter@xs4all.nl
Date: Sun, 22 Jun 2014 13:31:26 +0200
Subject: [PATCH] Remove ##sys#expand-home-path as shell expansion has no
 place in a filesystem API.

The functionality is now available as a separate egg for those who
need it.  An added advantage is that expansion must be explicitly
performed, and that the egg can be developed separately.

Thanks to Florian Zumbiehl.
---
 NEWS  |3 +
 eval.scm  |2 -
 files.scm |   14 ++---
 library.scm   |  126 +++--
 manual/Extensions to the standard |6 --
 posix-common.scm  |   35 +--
 posixunix.scm |   78 +++
 posixwin.scm  |   12 ++--
 tests/path-tests.scm  |9 +--
 9 files changed, 111 insertions(+), 174 deletions(-)

diff --git a/NEWS b/NEWS
index a9ded9e..6feb672 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@
   - Unit tcp now implicitly depends on ports instead of extras.
  This may break programs which don't use modules and forgot to
  require extras but use procedures from it.
+  - Removed deprecated implicit expansion of $VAR- and ~ in pathnames.
+ The ~-expansion functionality is now available in the
+ pathname-expand egg (#1001, #1079) (thanks to Florian Zumbiehl).
 
 - Unit lolevel:
   - Restore long-lost but still documented vector-like? procedure (#983)
diff --git a/eval.scm b/eval.scm
index fea8a02..a131fbf 100644
--- a/eval.scm
+++ b/eval.scm
@@ -966,8 +966,6 @@
 (##sys#signal-hook #:type-error 'load bad argument type - not a port or 
string x) )
   (set! ##sys#load 
 (lambda (input evaluator pf #!optional timer printer)
-  (when (string? input) 
-   (set! input (##sys#expand-home-path input)) )
   (let* ((fname 
  (cond [(port? input) #f]
[(not (string? input)) (badfile input)]
diff --git a/files.scm b/files.scm
index 805eb1d..e85f805 100644
--- a/files.scm
+++ b/files.scm
@@ -385,14 +385,12 @@ EOF
(display p out) )
  (cdr parts))
 (when (fx= i prev) (##sys#write-char-0 sep out))
-(let* ((r1 (get-output-string out))
-   (r (##sys#expand-home-path r1)))
-  (when (string=? r1 r)
-(when abspath 
-  (set! r (##sys#string-append (string sep) r)))
-(when drive
-  (set! r (##sys#string-append drive r
-  r
+(let ((r (get-output-string out)))
+