>>>>> "Bernard" == Bernard Dautrevaux <[EMAIL PROTECTED]> writes:

Bernard> If a path starts by a double '/' (that is for any UNC path,
Bernard> quite often found on DOS boxes), we will strip one of these
Bernard> leading '/'; thus the directory part of
Bernard> "//server00/home/me/myfile" (which is myfile in my home
Bernard> directory on my NT box) became "/serve00/home/me" which is an
Bernard> unknown directory... 8-)

No no:

#! /bin/sh

format="%12s %12s %12s\n"

# alexandre, GNU dirname
printf "$format" "dir" "al" "dn"
# echo "" al dn

for dir in //1 /1 ./1 ../../2 \
           //1/ /1/ ./1/ ../../2 \
           //1/3 /1/3 ./1/3 ../../2/3 \
           //1/3/// /1/3/// ./1/3/// ../../2/3/// \
           //1//3/ /1//3/ ./1//3/ ../../2//3/
do
  al=`echo $dir | sed '/^\/*$/!s,//*$,,;s,[^/]*$,,;s,//*$,/,;/^\/$/!s,/$,,'`
  dn=`command dirname $dir`
  printf "$format" "$dir" "$al" "$dn"
  # echo "$dir  $al     $dn"
done

% sh /tmp/dirname.sh
         dir           al           dn
         //1            /            /
          /1            /            /
         ./1            .            .
     ../../2        ../..        ../..
        //1/            /            /
         /1/            /            /
        ./1/            .            .
     ../../2        ../..        ../..
       //1/3          //1          //1              <========
        /1/3           /1           /1
       ./1/3          ./1          ./1
   ../../2/3      ../../2      ../../2
    //1/3///          //1          //1              <========
     /1/3///           /1           /1
    ./1/3///          ./1          ./1
../../2/3///      ../../2      ../../2
     //1//3/          //1          //1
      /1//3/           /1           /1
     ./1//3/          ./1          ./1
 ../../2//3/      ../../2      ../../2

Unless you are referring to the case `//1' -> `1'.


Bernard> I send this in answer to this "jokeward" path as I just read
Bernard> all this thread now, and think it is appropriate as I request
Bernard> some "bizarre-ward" compatibility ;-)

Foreignward compatibility is indeed desired.  But are you sure we're
losing here?  Mark, or Eli, what do you think we should do?  We're
trying to implement dirname.  `al' is the current CVS solution.

        Akim

Reply via email to