Re: weird ksh '~' substitution - ksh bug?

2011-12-16 Thread Otto Moerbeek
On Fri, Dec 16, 2011 at 09:47:54AM +0100, LEVAI Daniel wrote:

 Hi!
 
 
 I can't get my around this:
 
 $ pwd
 /home/daniell
 
 $ cd ~/stuff/
 ksh: cd: /home/daniell/~/stuff - No such file or directory
 
 $ cd ~/stuff/
 $ pwd
 /home/daniell/stuff
 
 
 It seems  ~  is substituted in the first case, but it is not replaced,
 and it remained in the list.
 
 What is even more weird:
 $ echo ~/stuff
 ~/stuff
 
 ^^^ here it is not even substituted.
 
 $ echo ~/stuff
 /home/daniell/stuff
 
 ^^^ whereas here it is.
 
 
 I suspect this is not a feature?

Tilde expansion is tricky stuff. If you read how it is defined (man
ksh), it says:


The characters following the tilde, up to the first `/', if any, are
assumed to be a login name. 
...
If the login name is not found in the password file or if any quoting
or parameter substitution occurs in the login name, no substitution is
performed. 


I think that explains your testcases.

-Otto

  
 
 
 Daniel
 
 -- 
 LIVAI Daniel
 PGP key ID = 0x83B63A8F
 Key fingerprint = DBEC C66B A47A DFA2 792D  650C C69B BE4C 83B6 3A8F



Re: weird ksh '~' substitution - ksh bug?

2011-12-16 Thread Dieter Schön
2011/12/16 LEVAI Daniel l...@ecentrum.hu:

 I suspect this is not a feature?

looks like it is a feature:
man ksh, Tilde expansion, first paragraph, second and last sentence:
The characters following the tilde, up to the first `/',
if any, are assumed to be a login name.
If  [..] or if any quoting
or parameter substitution occurs in the login name, no substitution is
performed.

dieter



Re: weird ksh '~' substitution - ksh bug?

2011-12-16 Thread LEVAI Daniel
On Fri, Dec 16, 2011 at 10:55:08 +0100, Otto Moerbeek wrote:
 On Fri, Dec 16, 2011 at 09:47:54AM +0100, LEVAI Daniel wrote:
[...]
 I think that explains your testcases.

On Fri, Dec 16, 2011 at 11:05:50 +0100, Dieter Schvn wrote:
 2011/12/16 LEVAI Daniel l...@ecentrum.hu:
 
  I suspect this is not a feature?
 
 looks like it is a feature:
[...]


Thanks for both of You.
I systematically beleive that there is nothing more to read in ksh's man
page. And I am always wrong...


Daniel

-- 
LIVAI Daniel
PGP key ID = 0x83B63A8F
Key fingerprint = DBEC C66B A47A DFA2 792D  650C C69B BE4C 83B6 3A8F



Re: weird ksh '~' substitution - ksh bug?

2011-12-16 Thread Steven McDonald
On Fri, 16 Dec 2011 09:47:54 +0100
LEVAI Daniel l...@ecentrum.hu wrote:

 $ cd ~/stuff/
 ksh: cd: /home/daniell/~/stuff - No such file or directory
 
[snip]
 It seems  ~  is substituted in the first case

Just a correction here: I don't think it's being substituted. Rather,
the lack of a leading / is causing it to be interpreted as a relative
path, and you are already working in /home/daniell/.

As for your actual question, I'll wait for some of the more experienced
OpenBSDers to come along with an answer and go back to lurking the
list. :)