I'm trying to distinguish between a case where there is no parameter on the command line and where there is piped input. The code below works under Win-32 but under Linux Eof() waits for input:

  IF ParamCount = 0 THEN BEGIN          (* Case (1) or (2) *)
    debug('No parameters (case 1 or 2)');
    TRY
      AssignFile(input, '');            (* Standard input               *)
{$IOCHECKS OFF }
      Reset(input);     // Returns zero
      TRY
        IF Eof(input) THEN BEGIN        (* Case (1)     *)
          debug('At EOF (case 1)');
{$IOCHECKS ON }

// Nothing on command line.

        END ELSE BEGIN                  (* Case (2)     *)
          debug('Not at EOF (case 2)');

// Got piped input.

If I start it under linux by piping an eof (i.e. echo -n |) it works.

I'm sure this is something that's been looked at before- how do I get it to 
work?

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to