\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#402: General Platform UNC Support}
\date{July 16, 2011}
\author{Jan Nijtmans}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#402}&\textbf{General Platform UNC Support}\\\hline
Author&

Jan Nijtmans \tipmail{jan.nijtmans}{users.sf.net}
\\
Created&Saturday, \(\text{16}^{\text{th}}\) July 2011\\
Type&Project\\
Tcl Version&\(8.7\)\\
State&Draft\\
Vote&Pending\\
Version&\tipversion$Revision: 1.2 $\\
Keywords&Tcl\\
Post History&\\
Discussions To&Tcl Core list\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

Both Windows and Cygwin interpret paths starting with \textbf{//} as a special prefix, indicating that the path has the form: \textbf{//server/share/file\_path}. Windows has built-in handling of such paths built-in. UNIX doesn't have this. It could be implemented through a VFS extension, but there is one problem: File normalization on UNIX collapes multiple slashes into a single slash, so this would convert the UNC path into a normal path. This makes it impossible to implement a VFS extension which uses \textbf{//} as prefix, implementing connection to a Samba server using the UNC path format.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

At the moment, Cygwin and Windows have built-in a special case that paths starting with double-slash will not be collapsed into a single slash. UNIX does not do that. This change will allow a single uniform format for accessing (Samba) shares on external machines using the path format \textbf{//server/share/file\_path}. On Windows and Cygwin this already works, because it is built-in Windows functionality. On UNIX a VFS extension could be developed which does the same.

\section{Specification}

This document proposes:
\begin{itemize}
\item{}
Extend the special case built-in for Windows and Cygwin to UNIX, so paths starting with double-slash will no longer normalize to paths starting with a single slash.

\textbf{POTENTIAL INCOMPATIBILITY}
\item{}
As \textbf{//} becomes a special prefix, the \textbf{file split} will return \textbf{//} as its first list element when the original path starts with a double slash.
\end{itemize}

\section{Compatibility}

On UNIX, this means that paths like \textbf{//usr/bin/tclsh} might no longer do what it did earlier, if a VFS exists which uses \textbf{//} as path prefix. If no such VFS exists, it will probably still work, only comparing normalized paths will no longer regard \textbf{//\tiplangle{}foo\tiprangle{}} as equal to \textbf{/\tiplangle{}foo\tiprangle{}}.

Handling of multiple slashes in other locations of the string will not change. So normalizing \textbf{/foo//bar} will still give \textbf{/foo/bar}. The most likely cause of multiple slashes appearing in a path is because of appending a file name to a path which already ends with a slash, e.g.
\begingroup\small\begin{verbatim}
set dir "somedir/"
set path $dir/filename
\end{verbatim}
\endgroup

Of course, the \textbf{file join} command does not have this danger:
\begingroup\small\begin{verbatim}
set dir "somedir/"
set path [file join $dir filename]
\end{verbatim}
\endgroup

On Windows and Cygwin, there is no change in behavior at all.

\section{Alternatives}

Variations are possible in the handling of paths starting with 3 or more slashes. The current TIP implementation collapes more than 2 slashes to exactly 2 slashes, as the current Windows and Cygwin implementations do.

\section{Reference Implementation}

A reference implementation is available at \url{http://core.tcl.tk/tcl} in branch \textit{jn-unc-vfs}.

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\end{document}
