Add environment variable.
authorRichard Jones <rjones@redhat.com>
Wed, 10 Mar 2010 12:58:09 +0000 (12:58 +0000)
committerRichard Jones <rjones@redhat.com>
Wed, 10 Mar 2010 12:58:09 +0000 (12:58 +0000)
techtalk-pse.pl

index e050120..6bd310f 100755 (executable)
@@ -191,6 +191,11 @@ if (@ARGV > 0) {
     }
 }
 
     }
 }
 
+# Get the talk directory and set environment variable $talkdir
+# which is inherited by all the scripts.
+my $talkdir = getcwd;
+$ENV{talkdir} = $talkdir;
+
 # Get the files.
 my @files;
 my %files;
 # Get the files.
 my @files;
 my %files;
@@ -292,9 +297,10 @@ sub show_slide
         my @cmd = ($0, "--mozembed");
         push @cmd, "--mozembed-first" if exists $slide->{first};
         push @cmd, "--mozembed-last" if exists $slide->{last};
         my @cmd = ($0, "--mozembed");
         push @cmd, "--mozembed-first" if exists $slide->{first};
         push @cmd, "--mozembed-last" if exists $slide->{last};
-        my $cwd = getcwd;
-        my $url = "file://" . $cwd . "/" . $slide->{name};
+        my $url = "file://$talkdir/" . $slide->{name};
         push @cmd, $url;
         push @cmd, $url;
+       print STDERR "running subcommand: ", join (" ", @cmd), "\n"
+           if $verbose;
         system (@cmd);
         die "failed to execute subcommand: ", join(" ", @cmd), ": $!\n"
             if $? == -1;
         system (@cmd);
         die "failed to execute subcommand: ", join(" ", @cmd), ": $!\n"
             if $? == -1;
@@ -647,6 +653,13 @@ When running shell scripts, the current directory is also set to be
 the directory containing the talk files, so the same rules about using
 relative paths apply there too.
 
 the directory containing the talk files, so the same rules about using
 relative paths apply there too.
 
+The environment variable C<$talkdir> is exported to scripts and it
+contains the absolute path of the directory containing the talk files.
+When a script is run, the current directory is the same as
+C<$talkdir>, but if your script changes directory (eg. into a
+subdirectory containing supporting files) then it can be useful to use
+C<$talkdir> to refer back to the original directory.
+
 =head1 WHAT MAKES A GOOD TALK
 
 I like what Edward Tufte writes, for example his evisceration of
 =head1 WHAT MAKES A GOOD TALK
 
 I like what Edward Tufte writes, for example his evisceration of