summaryrefslogtreecommitdiff
path: root/ipl/progs/comfiles.icn
blob: faabc61c816bd852adf3add1a984dcdef361acf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
############################################################################
#
#	File:     comfiles.icn
#
#	Subject:  Program to list common files in two directories
#
#	Author:   Ralph E. Griswold
#
#	Date:     March 21, 1994
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This program lists common file names in two directories given as
#  command-line arguments.
#
############################################################################
#
#  Requires:  UNIX
#
############################################################################

procedure main(args)
   local dir1, dir2, set1, set2, set3, input1, input2

   dir1 := args[1] | stop("*** no directories specified")
   dir2 := args[2] | stop("*** no second directory specified")

   set1 := set()
   set2 := set()

   input1 := open("ls " || dir1, "p")
   input2 := open("ls " || dir2, "p")

   every insert(set1, !input1)
   every insert(set2, !input2)

   set3 := set1 ** set2

   if *set3 = 0 then write("no common file names")
   else every write(!set3)

end