TIP #315: ADD PATHSEPARATOR TO TCL_PLATFORM ARRAY =================================================== Version: $Revision: 1.5 $ Author: Hai Vu State: Final Type: Project Tcl-Version: 8.6 Vote: Done Created: Friday, 04 April 2008 URL: https://tip.tcl-lang.org315.html Post-History: ------------------------------------------------------------------------- ABSTRACT ========== This TIP proposes a mechanism for determining the platform's path separator. The path separator is currently ":" in Unix and ";" in DOS/Windows. 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 *tcl_platform* array, *pathSeparator*, which describes the path separator for the current platform. EXAMPLE USAGE =============== The following example prints each component of the PATH environment on a separate line: set pathList [split $env(PATH) $tcl_platform(pathSeparator)] foreach path $pathList { puts $pathList } Alternatively: puts [string map [list $tcl_platform(pathSeparator) \n] $env(PATH)] COPYRIGHT =========== This document has been placed in the public domain. ------------------------------------------------------------------------- TIP AutoGenerator - written by Donal K. Fellows