summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ifplatform
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-09-10 23:47:34 +0000
committerKarl Berry <karl@freefriends.org>2009-09-10 23:47:34 +0000
commitd4c54e52fe8e42b8ce9b160c70d897bb1d06eee7 (patch)
tree0e960fee5fb176d8b6c8ce0af53beedc386a1bd7 /Master/texmf-dist/tex/latex/ifplatform
parentbfd31432fa7c95ab364bf41ef873316bcb7fd110 (diff)
ifplatform update (10sep09)
git-svn-id: svn://tug.org/texlive/trunk@15217 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/ifplatform')
-rw-r--r--Master/texmf-dist/tex/latex/ifplatform/ifplatform.sty144
1 files changed, 100 insertions, 44 deletions
diff --git a/Master/texmf-dist/tex/latex/ifplatform/ifplatform.sty b/Master/texmf-dist/tex/latex/ifplatform/ifplatform.sty
index ed0f046fcde..cd7cfe51318 100644
--- a/Master/texmf-dist/tex/latex/ifplatform/ifplatform.sty
+++ b/Master/texmf-dist/tex/latex/ifplatform/ifplatform.sty
@@ -5,75 +5,131 @@
%% The original source files were:
%%
%% ifplatform.dtx (with options: `package')
-%% ___________________________________________________
-%% Copyright (C) 2007 Will Robertson & Johannes Große
+%% _________________________________________________________
+%% Copyright (C) 2007, 2009 Will Robertson & Johannes Große
%% License information appended.
\ProvidesPackage{ifplatform}
- [2007/11/18 v0.2 Testing for the operating system]
+ [2009/09/10 v0.3a Testing for the operating system]
+\RequirePackage{pdftexcmds,catchfile}
\newif\ifshellescape
\newif\ifwindows
\newif\ifmacosx
\newif\iflinux
+\newif\ifcygwin
\newcommand\windowsname{Windows}
+\newcommand\notwindowsname{*NIX}
\newcommand\linuxname{Linux}
\newcommand\macosxname{Mac\,OS\,X}
+\newcommand\cygwinname{Cygwin}
\newcommand\unknownplatform{[Unknown]}
\edef\ip@file{\jobname.w18}
-\edef\ip@sig{write18-test-\the\year\the\month\the\day\the\time}
-\edef\ip@win{'\ip@sig'}
-\def\ip@read@file{%
- \newread\instream
- \openin\instream=\ip@file
- \@tempcnta=\endlinechar
- \endlinechar=-1
- \read\instream to\@tempa
- \endlinechar=\@tempcnta
- \closein\instream}
-\immediate\write18{echo \ip@win >"\ip@file"}
-\IfFileExists{\ip@file}{\shellescapetrue}{\shellescapefalse\endinput}
-\ip@read@file
-\ifx\@tempa\ip@sig
- \windowsfalse
+\newif\if@ip@nix@
+\ifnum\pdf@shellescape=1\relax
+ \shellescapetrue
\else
- \ifx\@tempa\ip@win
- \windowstrue
- \else
- \PackageError{ifplatform}
- {There is a problem. Please delete the file \ip@file.}
- {Somehow an old file is lying around telling me the wrong things.
- \MessageBreak This should never happen. Please let us know when it does!}
+ \PackageWarningNoLine{ifplatform}{^^J \space\space\space
+ shell escape is disabled,
+ so I can only detect \@backslashchar ifwindows%
+ }
+\fi
+\def\ip@cantdecide{%
+ \PackageWarningNoLine{ifplatform}{^^J \space\space\space
+ I can't tell if this is Windows or *nix;
+ you appear to be both%
+ }%
+}
+\IfFileExists{nul:}{\@ip@nix@false}{\@ip@nix@true}
+\IfFileExists{/dev/null}{\windowsfalse}{\windowstrue}
+\edef\ip@windows@echo@test{echo \string# > "\ip@file"}
+\def\ip@backupplan{%
+ \IfFileExists{\ip@file}{%
+ \PackageWarningNoLine{ifplatform}{^^J \space\space\space
+ Please delete the file "\ip@file" and try again%
+ }%
+ \ip@cantdecide
+ }{%
+ \immediate\write18{\ip@windows@echo@test}%
+ \IfFileExists{\ip@file}{%
+ \immediate\write18{del "\ip@file"}%
+ \windowstrue
+ }{%
+ \@ip@nix@true
+ }%
+ }%
+}
+\ifwindows
+ \if@ip@nix@
+ \PackageWarningNoLine{ifplatform}{^^J \space\space\space
+ I can't tell if this is Windows or *nix;
+ you appear to be neither%
+ }
+ \fi
+\else
+ \if@ip@nix@\else
+ \ifshellescape
+ \ip@backupplan
+ \else
+ \ip@cantdecide
+ \fi
\fi
\fi
-\ifwindows\else
- \immediate\write18{uname -s > "\ip@file"}
- \ip@read@file
- \def\@tempb{Linux}
- \ifx\@tempa\@tempb
- \linuxtrue
- \else
- \def\@tempb{Darwin}
+\def\ip@only@six#1#2#3#4#5#6#7\@nil{#1#2#3#4#5#6}
+\if@ip@nix@
+\ifshellescape
+ \ifwindows\else
+ \immediate\write18{uname -s > "\ip@file"}
+ \CatchFileDef\@tempa{\ip@file}{}
+ \immediate\write18{rm -- "\ip@file"}
+ \edef\@tempa{\expandafter\zap@space\@tempa\@empty}
+ \def\@tempb{Linux}
\ifx\@tempa\@tempb
- \macosxtrue
+ \linuxtrue
\else
- \edef\unknownplatform{\@tempa}
+ \def\@tempb{Darwin}
+ \ifx\@tempa\@tempb
+ \macosxtrue
+ \else
+ \def\@tempb{CYGWIN}
+ \edef\@tempc{\expandafter\ip@only@six\@tempa------\@nil}
+ \ifx\@tempb\@tempc
+ \cygwintrue
+ \else
+ \edef\unknownplatform{\@tempa}
+ \fi
+ \fi
\fi
\fi
-\fi
+\fi\fi
\edef\platformname{%
- \ifwindows\noexpand\windowsname\else
- \iflinux \noexpand\linuxname\else
- \ifmacosx \noexpand\macosxname\else
+ \ifwindows
+ \noexpand\windowsname
+ \else
+ \ifshellescape
+ \iflinux
+ \noexpand\linuxname
+ \else
+ \ifmacosx
+ \noexpand\macosxname
+ \else
+ \ifcygwin
+ \noexpand\cygwinname
+ \else
\noexpand\unknownplatform
- \fi\fi\fi}
-\immediate\write18{\ifwindows del \else rm -- \fi "\ip@file"}
-%% Copyright (C) 2007 by Will Robertson & Johannes Große
+ \fi
+ \fi
+ \fi
+ \else
+ \noexpand\notwindowsname
+ \fi
+ \fi
+}
+%% Copyright (C) 2007, 2009 by Will Robertson & Johannes Große
%%
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%%
-%% This work is "maintained" (as per LPPL maintenance status)
-%% by Will Robertson.
+%% This work is "author-maintained" by Will Robertson.
%%
%% This work consists of the file ifplatform.dtx
%% and the derived files ifplatform.pdf,