For the hurried, skip to the bottom few lines: 'Revised suggestion'.
In between, some user-oriented thoughts on 'realpath' which unfortunately
might miss various salient points.

On Wed, 20 May 2009 00:54:04 -0400
"A. Costa" <agco...@gis.net> hastily suggested:

> ...if the error message read:
> 
>       /dev/vb1: No such file or directory
> 
> ...it wouldn't have confused me long...

After reconsideration, no that message could confuse a user who might
wonder if the missing file was some absent program called by the
'realpath' command.  Needs context.

The "No such file or directory" error also shows up for files that
never existed:

        % mkdir /tmp/links
        % cd /tmp/links
        % echo hello > textfile.txt

        # now do an 'ls' for that file, and one that's not there.
        % ls -log textfile.txt nosuchfile.txt
        ls: cannot access nosuchfile.txt: No such file or directory
        -rw-r--r-- 1 6 May 24 17:32 textfile.txt
        
        # add a dangling symlink
        % ln -s nosuchfile.txt dangler
        
        # show how 'ls' sees these.
        % ls -log textfile.txt nosuchfile.txt dangler
        ls: cannot access nosuchfile.txt: No such file or directory
        lrwxrwxrwx 1 14 May 24 17:34 dangler -> nosuchfile.txt
        -rw-r--r-- 1  6 May 24 17:32 textfile.txt
        
        # compare how 'realpath' & 'readlink -f' behave:
        % realpath textfile.txt nosuchfile.txt dangler
        /tmp/textfile.txt
        nosuchfile.txt: No such file or directory
        dangler: No such file or directory
        
        % for f in textfile.txt nosuchfile.txt dangler ; do readlink -f $f ; 
done
        /tmp/textfile.txt
        /tmp/nosuchfile.txt
        /tmp/nosuchfile.txt

This error code of '0' looks wrong for 'readlink -f':

        % readlink -f  nosuchfile.txt; echo $?
        /tmp/nosuchfile.txt
        0

...but that'd be another bug report.

Consider a case of many chained symlinks:

        % prev=textfile.txt ; for f  in a b c d e f g h i j k ; do ln -s $prev 
$f ; prev=$f ; done
        % ls -log
        total 1
        lrwxrwxrwx 1 12 May 24 17:47 a -> textfile.txt
        lrwxrwxrwx 1  1 May 24 17:47 b -> a
        lrwxrwxrwx 1  1 May 24 17:47 c -> b
        lrwxrwxrwx 1  1 May 24 17:47 d -> c
        lrwxrwxrwx 1 14 May 24 17:34 dangler -> nosuchfile.txt
        lrwxrwxrwx 1  1 May 24 17:47 e -> d
        lrwxrwxrwx 1  1 May 24 17:47 f -> e
        lrwxrwxrwx 1  1 May 24 17:47 g -> f
        lrwxrwxrwx 1  1 May 24 17:47 h -> g
        lrwxrwxrwx 1  1 May 24 17:47 i -> h
        lrwxrwxrwx 1  1 May 24 17:47 j -> i
        lrwxrwxrwx 1  1 May 24 17:47 k -> j
        -rw-r--r-- 1  6 May 24 17:32 textfile.txt
        
        % realpath k
        /tmp/links/textfile.txt
        % readlink -f k
        /tmp/links/textfile.txt

        # now remove a symlink
        % rm c
        % realpath k
        k: No such file or directory
        % readlink -f k
        /tmp/links/c

Both errors confuse, 'readlink -f' tends to suggest 'c' exists.
'realpath' (even if the user knows what the error message really means)
doesn't help show where the chain breaks.

Revised suggestion, provide context, something like:

        % realpath k
        error: dangling symlink chain, '/tmp/links/k > /tmp/links/j > 
/tmp/links/i > /tmp/links/h > /tmp/links/g > /tmp/links/f > /tmp/links/e > 
/tmp/links/d > /tmp/links/c', but '/tmp/links/c' does not exist.

HTH...



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to