#! /local/bin/perl ###################################################################### # $Header: /loc/adm/slink-1.0/src/slink-5.0/RCS/truename,v 1.2 1996/05/11 02:38:57 couch Exp couch $ # TRUENAME: generate the true name of a node in a UNIX filesystem. # Revision 5.0 # by # Alva L. Couch, Greg Owen # Associate Prof. of EE/CS Xerox Information Systems # Department of EE/CS Peabody, MA 02146 # Tufts University, gowen@xis.xerox.com # Medford, Massachusetts, 02155. # couch@cs.tufts.edu # # Copyright (C) 1996 by Alva L. Couch and Greg Owen # # This file is part of SLINK # # SLINK 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. # # SLINK 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 CC; see the file COPYING. If not, write to # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ###################################################################### # Truename computes the true absolute pathname of a file, # which is an absolute pathname where no component is a # symbolic link. It takes an arbitrary number of arguments # and computes the true name of each of them. # options include: # -verbose: report on links traversed as you perform the truename. # -equiv: report whole equivalence classes of names rather than # just the single true name. ###################################################################### require 5.001; require "getcwd.pl"; require "newgetopt.pl"; use Slink::TrueName(qw(truename truepaths)); use strict; $main::opt_verbose = 0; $main::opt_equiv = 0; if (!&NGetOpt('-','verbose','equiv')) { print STDERR "truename usage:\n"; print STDERR "truename [-verbose] [-equiv] path1 path2 ...\n"; print STDERR " -verbose: print traversal history\n"; print STDERR " -equiv: print the path equivalence class for each path\n"; exit(1); } $Slink::TrueName::opt_verbose = $main::opt_verbose; my $cwd = &getcwd; my $link; foreach $link (@ARGV) { if (!$main::opt_equiv) { my $true = &truename($link,$cwd); print "$true\n" if $true ne ''; } else { my $equiv = &truepaths($link,$cwd); my @equiv = sort keys %$equiv; $equiv = join(' ',@equiv); print "$equiv\n"; } } exit(0);