$! x11--decw$include.com $ v = 'f$verify(0)' $! $! Make [-]X11.dir and [-]decw$include.dir point at the same files $! instead of having duplicate copies. $! $ com_fil = f$environment("PROCEDURE") $ old_def = f$environment("DEFAULT") $ set default 'f$string(f$parse("_.;",com_fil) - "_.;")' $! $ echo = "write sys$output" $ de_protect = "set file /Protection=(S:rwed,O:rwed)" $ hard_link_as = "set file /Enter=" $ remove = "set file /Remove" $ delete = "delete /noConfirm/noLog" $ rename = "rename /noNew_Version" $ cmp = "diff /Output=_NL:/Maximum=1" $! $ x11 = f$search("[-]X11.dir;1") $ dwi = f$search("[-]decw$include.dir;1") $ if x11.eqs."" !should be impossible; we expect this .com file to be in there! $ then $ if dwi.eqs."" $ then echo "X11--decw$include error! Both directories missing?" $ else echo "Creating X11.dir as synonym for decw$include.dir." $! instead of entering decw$include.dir as X11.dir, rename to force $! X11.dir to control the file header and then enter the opposite way $ rename [-]decw$include.dir;1 [-]X11.dir;1 $ hard_link_as [-]decw$include.dir;1 [-]X11.dir;1 $ endif $ else $ if dwi.eqs."" $ then echo "Creating decw$include.dir as synonym for X11.dir." $ hard_link_as [-]decw$include.dir;1 [-]X11.dir;1 $ else $! both directories already exist; try to reconcile them $ x11_did = f$file_attr(x11,"FID") $ dwi_did = f$file_attr(dwi,"FID") $ if x11_did.eqs.dwi_did $ then echo "decw$include.dir is already a synonym for X11.dir; no fix needed." $ else echo "Comparing decw$include.dir with X11.dir..." $ if f$search("[-.decw$include]*.*;",0).eqs."" $ then echo "Replacing empty decw$include.dir with synonym to X11.dir." $ de_protect [-]decw$include.dir;1 $ delete [-]decw$include.dir;1 $ hard_link_as [-]decw$include.dir;1 [-]X11.dir;1 $ else $ if f$search("[-.X11]*.*;",0).eqs."" $ then echo "Replacing empty X11.dir with synonym to decw$include.dir." $ de_protect [-]X11.dir;1 $ delete [-]X11.dir;1 $! instead of entering decw$include.dir as X11.dir, rename to force $! X11.dir to control the file header and then enter the opposite way $ rename [-]decw$include.dir;1 [-]X11.dir;1 $ hard_link_as [-]decw$include.dir;1 [-]X11.dir;1 $ else $ same_contents = 0 $ same_files = 0 $ x_parent = 0 $ d_parent = 0 $loop: $ d = f$search("[-.decw$include]*.*;",1) $ x = f$search("[-.X11]*.*;",2) $ if d.eqs."" .and. x.eqs."" then goto done $ if d.eqs."" .or. x.eqs."" then goto oops $ if f$file_attr(d,"FID").eqs.f$file_attr(x,"FID") $ then $ same_files = same_files + 1 $ if f$file_attr(d,"DID").eqs.x11_did then x_parent = x_parent + 1 $ if f$file_attr(d,"DID").eqs.dwi_did then d_parent = d_parent + 1 $ else $ d_ = f$parse("::_:[_]",d,,,"SYNTAX_ONLY") - "::_:[_]" $ x_ = f$parse("::_:[_]",x,,,"SYNTAX_ONLY") - "::_:[_]" $ if d_.nes.x_ then goto oops $ define/User sys$error _NL: $ cmp 'd' 'x' $ if .not.$status then goto oops $ same_contents = same_contents + 1 $ endif $ goto loop $done: if same_files.eq.0 $ then echo "X11.dir and decw$include.dir contain copies of the same files." $ echo "Deleting duplicates from decw$include." $ de_protect [-.decw$include]*.*;*,[-]decw$include.dir;1 $ delete [-.decw$include]*.*;*,[-]decw$include.dir;1 $ echo "Replacing decw$include.dir with synonym to X11.dir." $ hard_link_as [-]decw$include.dir;1 [-]X11.dir;1 $ else echo "X11.dir and decw$include.dir contain entries for the same files." $ if x_parent.eq.same_files $ then echo "Removing them from decw$include and replacing it with synonym to X11." $ de_protect [-.decw$include]*.*;*,[-]decw$include.dir;1 $ remove [-.decw$include]*.*;* $ delete [-]decw$include.dir;1 $ hard_link_as [-]decw$include.dir;1 [-]X11.dir;1 $ else $ if d_parent.eq.same_files $ then echo "Removing them from decw$include, then replacing it with synonym to X11." $ de_protect [-.X11]*.*;*,[-]decw$include.dir;1 $ remove [-.X11]*.*;* $ rename [-.decw$include]*.*;* [-.X11] $ delete [-]decw$include.dir;1 $ hard_link_as [-]decw$include.dir;1 [-]X11.dir;1 $ else echo "Mixed collection of files; fixup too complicated to pursue." $! mixed parentage; how could such a mess occur? $ endif $ endif $ endif $ goto exit $oops: echo "X11.dir and decw$include.dir have different contents" $ echo "so a fixup into synonym directories cannot be done." $ endif $ endif $ endif $ endif $ endif $ $exit: $ set default 'old_def' $ exit 1 + 0*f$verify(v)