.bashrc: +function exx: cd into $extdir if it is the only one created (successfuly)
authorshort <>
Fri, 28 Jun 2002 01:31:09 +0000 (01:31 +0000)
committershort <>
Fri, 28 Jun 2002 01:31:09 +0000 (01:31 +0000)
 - sideeffect: exx function does >&2

.bashrc
bin/exx

diff --git a/.bashrc b/.bashrc
index df928dd..51d3b5a 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -113,6 +113,7 @@ function ctags {(unset ctags;
                find -type f -a '(' -name "*.[chC]" -o -name "*.cc" -o -name "*.java" ')'|ctags --file-tags -L -
        fi; );}; export -f ctags
 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}; export -f cpan
                find -type f -a '(' -name "*.[chC]" -o -name "*.cc" -o -name "*.java" ')'|ctags --file-tags -L -
        fi; );}; export -f ctags
 function cpan {(unset cpan; if [ $# = 0 ];then cpan;else perl -MCPAN -e "install qw($*);";fi; );}; export -f cpan
+function exx { cd "`unset exx;exx "$@"|tee /proc/self/fd/2|tail -n1|sed -n 's/^extdir=//p'`"; };export -f exx
 
 ulimit -c 0
 set +H
 
 ulimit -c 0
 set +H
diff --git a/bin/exx b/bin/exx
index 12de60d..c81dafe 100755 (executable)
--- a/bin/exx
+++ b/bin/exx
@@ -27,6 +27,7 @@ use constant FORMATS=>{
 die "Syntax: $0 <pathname((".join("|",map(".$_",sort keys %{+FORMATS})).")|=<ext>)>..."
                if !@ARGV;
 
 die "Syntax: $0 <pathname((".join("|",map(".$_",sort keys %{+FORMATS})).")|=<ext>)>..."
                if !@ARGV;
 
+my @extdirs;
 my $origdir=cwd;
 for my $fname (@ARGV) {
        my @parsed;
 my $origdir=cwd;
 for my $fname (@ARGV) {
        my @parsed;
@@ -65,8 +66,10 @@ for my $fname (@ARGV) {
        print "\t$extdir/:\n"; STDOUT->flush();
        my $rc;
        $rc=system $cmd and die "$cmd (rc=".($rc>>8)."): $!";
        print "\t$extdir/:\n"; STDOUT->flush();
        my $rc;
        $rc=system $cmd and die "$cmd (rc=".($rc>>8)."): $!";
+       push @extdirs,$extdir;
        }
        continue {
                chdir $origdir;
                }
        }
        continue {
                chdir $origdir;
                }
+print "extdir=".$extdirs[0]."\n" if 1==@extdirs;
 exit 0;
 exit 0;