"Fossies" - the Fresh Open Source Software Archive

Member "seed7/prg/which.sd7" (1 May 2017, 2741 Bytes) of package /linux/misc/seed7_05_20210223.tgz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 (********************************************************************)
    3 (*                                                                  *)
    4 (*  which.sd7     Locate in which directory a command is found.     *)
    5 (*  Copyright (C) 2015  Thomas Mertes                               *)
    6 (*                                                                  *)
    7 (*  This program is free software; you can redistribute it and/or   *)
    8 (*  modify it under the terms of the GNU General Public License as  *)
    9 (*  published by the Free Software Foundation; either version 2 of  *)
   10 (*  the License, or (at your option) any later version.             *)
   11 (*                                                                  *)
   12 (*  This program is distributed in the hope that it will be useful, *)
   13 (*  but WITHOUT ANY WARRANTY; without even the implied warranty of  *)
   14 (*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   *)
   15 (*  GNU General Public License for more details.                    *)
   16 (*                                                                  *)
   17 (*  You should have received a copy of the GNU General Public       *)
   18 (*  License along with this program; if not, write to the           *)
   19 (*  Free Software Foundation, Inc., 51 Franklin Street,             *)
   20 (*  Fifth Floor, Boston, MA  02110-1301, USA.                       *)
   21 (*                                                                  *)
   22 (********************************************************************)
   23 
   24 
   25 $ include "seed7_05.s7i";
   26   include "process.s7i";
   27 
   28 
   29 const proc: main is func
   30   local
   31     var string: command is "";
   32     var string: path is "";
   33     var string: filePath is "";
   34     var boolean: searching is TRUE;
   35     var boolean: first is TRUE;
   36   begin
   37     if length(argv(PROGRAM)) <> 1 then
   38       writeln("Which Version 1.0 - Locate in which directory a command is found.");
   39       writeln("Copyright (C) 2015 Thomas Mertes");
   40       writeln("This is free software; see the source for copying conditions.  There is NO");
   41       writeln("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.");
   42       writeln("Which is written in the Seed7 programming language");
   43       writeln("Homepage: http://seed7.sourceforge.net");
   44       writeln;
   45       writeln("usage: which command");
   46     else
   47       command := argv(PROGRAM)[1];
   48       filePath := commandPath(command);
   49       if filePath <> "" then
   50         writeln(filePath);
   51       else
   52         writeln(" ***** " <& command <& " not found in");
   53         for path range getSearchPath do
   54           if first then
   55             first := FALSE;
   56           else
   57             write(":");
   58           end if;
   59           write(path);
   60         end for;
   61         writeln;
   62       end if;
   63     end if;
   64   end func;