Summary
##sys#expand-home-path bug on OS X
Metadata
- Id: 4876c25fe0bd16478ec21a2cc20c2f3b10932e4e
- Trac id: 52
- Type: defect
- Reporter: zbigniew
- Owner: felix
- Cc:
- Status: closed
- Component: core libraries
- Estimated difficulty:
- Resolution: fixed
- Priority: minor
- Milestone:
- Version: 4.0.x
- Changetime: 2009-06-30 10:42:17 UTC
- Created: 2009-06-28 00:46:42 UTC
- Keywords:
Attachments
- 4876c25fe0bd16478ec21a2cc20c2f3b10932e4e/attachments/tilde-expander.diff.txt
Description
Plain tilde does not work properly. Did not check any other platform yet. Pretty sure this has been present forever.
#;2> (##sys#expand-home-path "~/tmp") "/Users/jim/tmp" #;3> (##sys#expand-home-path "~/") "/Users/jim/" #;4> (##sys#expand-home-path "~") "/home/"
Also affects derived procedures e.g.
#;3> (change-directory "~/tmp") #;4> (change-directory "~") Error: (change-directory) cannot change current directory - No such file or directory: "~"
Changes and comments
[2009-06-28 01:11:47 UTC] zbigniew wrote:
OK, I see this is done to support ~user -> /home/user, which can't be done reliably without getpwnam(3).
I would be satisfied with the simple fix of "~" -> (getenv "HOME"), while leaving "~user" broken, in ##sys#expand-home-path. As you probably wish to avoid a getpwnam call in library.scm.
However, the posix unit should really have its own expansion code used by change-directory etc., which uses getpwnam / getpwuid for tilde expansion.
I could produce a patch if you are interested.
[2009-06-28 04:35:57 UTC] zbigniew wrote:
Attached an attempt at fixing this. Creates a new parameter ##sys#tilde-expander used by ##sys#expand-home-path which, by default, just checks $HOME, but when the posixunix unit is loaded, will use either $HOME or user-information. posixwin currently uses the default behavior. Also if tilde-expansion fails the original unexpanded text will be used. it will do ~/tmp -> /tmp if $HOME is unset.
I did not touch canonical-path, which is also broken (worse). It is a bit hairy but could piggyback on this.
expand-home-path fix example
$ echo $HOME /Users/jim $ csi #;1> (##sys#expand-home-path "~") "/Users/jim" #;2> (##sys#expand-home-path "~jim") "/home/jim" #;3> (##sys#expand-home-path "~root") "/home/root" #;3> (##sys#expand-home-path "~/tmp") "/Users/jim/tmp" #;4> (use posix) ; loading library posix ... #;5> (##sys#expand-home-path "~") "/Users/jim" #;6> (##sys#expand-home-path "~jim") "/Users/jim" #;7> (##sys#expand-home-path "~/tmp") "/Users/jim/tmp" #;10> (##sys#expand-home-path "~root") "/var/root" #;11> (##sys#expand-home-path "~dummy") "~dummy" #;12> (unsetenv "HOME") #;13> (##sys#expand-home-path "~") "/Users/jim" #;14> (setenv "HOME" "/dummy") #;15> (##sys#expand-home-path "~/tmp") "/dummy/tmp" $ unset HOME; csi #;1> (##sys#expand-home-path "~") "~" #;1> (##sys#expand-home-path "~/tmp") "~/tmp"
Broken canonical-path example
#;2> (use posix) #;3> (canonical-path "~") "/Users/jim/~" #;4> (canonical-path "~/") "/Users/jim/" #;8> (canonical-path "~jim") "/Users/jim/~jim" #;9> (canonical-path "~/tmp") "/Users/jim/tmp"
[2009-06-28 04:47:36 UTC] zbigniew attached tilde-expander.diff.txt (description=patch to svn trunk)
[2009-06-29 15:25:15 UTC] felix changed status from new to assigned
[2009-06-29 15:25:15 UTC] felix set owner to felix
[2009-06-30 10:42:17 UTC] felix changed status from assigned to closed
[2009-06-30 10:42:17 UTC] felix set resolution to fixed
[2009-06-30 10:42:17 UTC] felix wrote:
"~user" was never officially supported - I can't remember, whether I added the "/home/" brokenness or not.
I will simply remove this feature - an initial "~" will expand into $HOME. `canonical-path` will be folded into `normalize-pathname` and simplified later.
See commit r15118