Bug 7368

Summary: mkdir -p builtin fails when a part of the path is a symlink
Product: Sisyphus Reporter: Fr. Br. George <george>
Component: zshAssignee: Fr. Br. George <george>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: normal    
Priority: P2 CC: arseny, george
Version: unstable   
Hardware: all   
OS: Linux   

Description Fr. Br. George 2005-07-14 23:04:50 MSD
Zsh have "files" plugin includeing "mkdir" buiiltin.
When using mkdir -p then, the builtin version fails on partially symlik-ed path.
E. g. when /home  is symlink-> /var/home, any first completion spams a
"_store_cache:mkdir:16: cannot make directory `/home': file exists" message when
trying to create $HOME/.zcompcache.

Look at this part of zsh-4.3.0-20050611/Src/Modules/files.c:

    121 domkdir(char *nam, char *path, mode_t mode, int p)
    122 {
    123     int err;
    124     mode_t oumask;
    125     char const *rpath = unmeta(path);
    126 
    127     if(p) {
    128         struct stat st;
    129 
    130         if(!lstat(rpath, &st) && S_ISDIR(st.st_mode))
    131             return 0;
    132     }

Here must be "stat" instead of "lstat", mustn't it?
Steps to Reproduce:
0. mv /home /var/home; ln -s /var/home /home # do it carefully :)
1. rm -rf ~/.zcompcache
2. apt-cache search a<TAB>

Actual Results:  
see message, no ~/.zcompcache is created

Expected Results:  
see no messages, ~/.zcompcache is created
Comment 1 at@altlinux.org 2005-07-21 23:35:59 MSD
Fixed in zsh-4.3.0-alt0.2.