@c Generated automatically from dosunix.pas
@c DO NOT CHANGE THIS FILE MANUALLY!

@example
@{
Some routines to support writing programs portable between Dos and
Unix. Perhaps it would be a good idea not to put features to make
Dos programs Unix-compatible (shell redirections) and vice versa
(reading Dos files from Unix) together into one unit, but rather
into two units, DosCompat and UnixCompat or so -- let's wait and
see, perhaps when more routines suited for this/these unit(s) will
be found, the design will become clearer...

Copyright (C) 1998-2000 Free Software Foundation, Inc.

Author: Frank Heckenbach <frank@@pascal.gnu.de>

This file is part of GNU Pascal.

GNU Pascal is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Pascal is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Pascal; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.

As a special exception, if you link this file with files compiled
with a GNU compiler to produce an executable, this does not cause
the resulting executable to be covered by the GNU General Public
License. This exception does not however invalidate any other
reasons why the executable file might be covered by the GNU General
Public License.
@}

@{$gnu-pascal@}
@{$if __GPC_RELEASE__ < 20000412@}
@{$error This unit requires GPC release 20000412 or newer.@}
@{$endif@}

unit DosUnix;

interface

uses GPC;

@{
  This function is meant to be used when you want to invoke a system
  shell command (e.g. via Execute or Exec from the Dos unit) and
  want to specify input/output redirections for the command invoked.
  It caters for the different syntax between DJGPP (with the @samp{redir}
  utility) and other systems.

  To use it, code your redirections in bash style (see the table
  below) in your command line string, pass this string to this
  function, and the function's result to Execute or the other
  routines.

  The function translates the following bash style redirections
  (characters in brackets are optional) into a redir call under Dos
  systems except EMX, and leave them unchanged under other systems.
  Note: @samp{redir} comes with DJGPP, but it should be possible to
  install it on other Dos systems as well. OS/2's shell, however,
  supports bash style redirections, I was told, so we don't
  translate on EMX.

  [0]<     file      redirect standard input from file
  [1]>[|]  file      redirect standard output to file
  [1]>>    file      append standard output to file
  [1]>&2             redirect standard output to standard error
  2>[|]    file      redirect standard error to file
  2>>      file      append standard error to file
  2>&1               redirect standard error to standard output
  &> file            redirect both standard output and standard
                     error to file
@}
function TranslateRedirections (const Command : String) : TString;

@{ Under Unix, translates CR/LF pairs to single LF characters when
  reading from f, and back when writing to f. Under Dos, does
  nothing because the run time system alrady does this job. In the
  result, you can read both Dos and Unix files, and files written
  will be Dos. @}
procedure AssignDos (var f : AnyFile; const Name : String);

@end example
