\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#315: Add pathSeparator to tcl\_platform Array}
\date{April 04, 2008}
\author{Hai Vu}
\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 \#315}&\textbf{Add pathSeparator to tcl\_platform Array}\\\hline
Author&

Hai Vu \tipmail{haivu2004}{gmail.com}
\\
Created&Friday, \(\text{4}^{\text{th}}\) April 2008\\
Type&Project\\
Tcl Version&\(8.6\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.5 $\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP proposes a mechanism for determining the platform's path separator. The path separator is currently ``:'' in Unix and ``;'' in DOS/Windows.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

Under Windows, the PATH environment variable consists of many paths, separated by semicolons (``;''). Meanwhile, Unix uses colon to separate the paths (``:''). Scripts that need to work on both platforms while parsing platform-specific PATH-like environment variables (PATH is just the most common of these) currently need to contain the mapping from platform-type to separator, but this is not especially flexible and some script authors are also inclined to forget about this particular difference.

Thus, to aid portability, this TIP proposes adding an element to the \textbf{tcl\_platform} array, \textbf{pathSeparator}, which describes the path separator for the current platform.

\section{Example Usage}

The following example prints each component of the PATH environment on a separate line:
\begingroup\small\begin{verbatim}
set pathList [split $env(PATH) $tcl_platform(pathSeparator)]
foreach path $pathList {
    puts $pathList
}
\end{verbatim}
\endgroup

Alternatively:
\begingroup\small\begin{verbatim}
puts [string map [list $tcl_platform(pathSeparator) \n] $env(PATH)]
\end{verbatim}
\endgroup

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

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