Matthew Boeh wrote:
> On Thu, Jul 24, 2008 at 12:52:54AM +0900, Yukihiro Matsumoto wrote:
>   
>> Hi,
>>
>> In message "Re: [ruby-core:17874] Re: Expand_Path:  New Patch - Modified Processing"
>>     on Mon, 21 Jul 2008 03:36:22 +0900, "C.E. Thornton" <admin / hawthorne-press.com> writes:
>>
>> |   It is not a failure of user name!
>> |
>> |   If the directory contains a dir named '~test', it is
>> |a perfectly acceptable dir name.  As long as the 'name'
>> |part of  '~name' is NOT a user name, it should be valid!
>> |
>> | Lets look at how BASH Processes these directories:
>> |
>> |      cd ~chuck     (A user name on my system)
>> |          returns /home/chuck  
>> |      cd ~test         (test is NOT a user name on my system)
>> |          returns 'current_dir/~test'    <== Why should this produce an error?
>>
>> Interestingly, zsh raises error for non-existing user name.
>>
>>   zsh% echo ~matz
>>   /home/matz
>>   zsh% echo ~foo
>>   zsh: no such user or named directory: foo
>>   zsh% echo /tmp/~foo
>>   /tmp/~foo
>>
>> Hence I don't consider this behavior a bug.
>>
>> 							matz.
>>
>>     
>
> That's actually configurable:
>
> % echo $SHELL
> /bin/zsh
> % /bin/zsh --version
> zsh 4.3.4 (x86_64-unknown-linux-gnu)
> % echo ~nothere
> ~nothere
> % setopt badpattern nomatch
> % echo ~nothere
> zsh: no such user or named directory: nothere
>
> I think part of the issue is that File.expand_path has at least two distinct 
> uses.  One is to transform a relative path with . and .. into an absolute 
> path, and the other is to expand tildes. This could be solved in one of three 
> ways: (1) adding another class method to File which only resolves relative 
> paths, (2) adding an argument to File.expand_path to skip the tilde expansion, 
> or (3) to somehow allow tildes to be escaped. Z shell permits the last of 
> these, even with "badpattern nomatch" set:
>
> % echo \~nothere
> ~nothere
>
>   
OK,

Then why does 'sh'

echo ~chuck
/home/~chuck
echo ~foo
~foo                   <== No error!
echo /tmp/~foo
/tmp/~foo

ADDITIONALLY, Rune Hammersland provided this:
I somewhat agree. Python also does this the same way as Bash [1]:

 >>> os.path.expanduser("~rune")
'/Users/rune'
 >>> os.path.expanduser("~asdf")
'~asdf'



NOW,

  Why should a function that expands relative paths to
absolute paths produce an ERROR when it can avoid it.

Thats what we are talking about.  I have a directory that
expand_path deliberately ignores and produces an error.

What is the rational behind that?

Chuck T.

-- 
Competency and chastity have much in common,
they both encompass their own punishment! 
 
-- C.E. Thornton -- Hawthorne Press --