From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ux2.cso.uiuc.edu ([128.174.5.3]) by hawkwind.utcs.toronto.edu with SMTP id <2408>; Wed, 17 Mar 1993 12:59:25 -0500 Received: by ux2.cso.uiuc.edu id AA13269 (5.67a/IDA-1.5 for sam-fans@hawkwind.utcs.toronto.edu); Wed, 17 Mar 1993 11:59:12 -0600 Date: Wed, 17 Mar 1993 12:59:12 -0500 From: Ed Kubaitis - CCSO Message-Id: <199303171759.AA13269@ux2.cso.uiuc.edu> To: sam-fans@hawkwind.utcs.toronto.edu Subject: scripts using 3/12 sam command pipe? Here's a pretty obvious one. Anyone else have one to share? Ed =============================================================================== #! /usr/local/bin/perl # # samtag - generate Sam commands from ctags(1) tags file # # usage: !samtag tag -OR- (select-tag-with-mouse) # >samtag $user = $ENV{'USER'}; $user = $ENV{'LOGNAME'} unless $user; $user || die "samtag: no USER or LOGNAME environment variable.\n"; $pipe = ".sam.$user"; $pipe .= ".$ENV{'DISPLAY'}" if $ENV{'DISPLAY'}; $Pipe = "/tmp/$pipe"; $Pipe = "/usr/tmp/$pipe" unless -p $Pipe; -p $Pipe || die "samtag: no sam pipe($pipe) in /tmp or /usr/tmp\n"; $Tag = shift; $Tag = unless $Tag; die "samtag: no tag specified." unless $Tag; open(Tags, "tags") || die "samtag: tags: $!\n"; while() { /^([^\t]+)\t([^\t]+)\t(.+)$/; $tag = $1; $file =$2; $re =$3; last if $tag eq $Tag } die "samtag: tag <$Tag> not found.\n" unless $tag eq $Tag; $re =~ s/([()*[\]])/\\$1/g; # escape metacharacters in re open(Pipe, ">$Pipe") || die "samtag: $Pipe: $!\n"; print Pipe "B $file\n$re\n"; close(Pipe);