summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLUtils.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/TeXLive/TLUtils.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm30
1 files changed, 20 insertions, 10 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index eb2e87e934e..87f9e9d7615 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -336,10 +336,15 @@ Return C<$path> with its trailing C</component> removed.
=cut
sub dirname {
- $_[0]=~/(.*)\/.*/;
- return "$1";
+ if ($_[0] =~ m!/!) { # dirname("foo/bar/baz") -> "foo/bar"
+ $_[0] =~ m!(.*)/.*!;
+ return $1;
+ } else { # dirname("ignore") -> "."
+ return ".";
+ }
}
+
=item C<basename($path)>
Return C<$path> with any leading directory components removed.
@@ -347,15 +352,20 @@ Return C<$path> with any leading directory components removed.
=cut
sub basename {
- $_[0]=~/.*\/(.*)/;
- return "$1";
+ if ($_[0] =~ m!/!) { # basename("foo/bar") -> "bar"
+ $_[0] =~ m!.*/(.*)!;
+ return $1;
+ } else { # basename("ignore") -> "ignore"
+ return $_[0];
+ }
}
+
=item C<dirname_and_basename($path)>
-Return C<dirname> and C<basename>. Example:
+Return both C<dirname> and C<basename>. Example:
- ($dir, $file)=dirname_and_basename($path);
+ ($dirpart,$filepart) = dirname_and_basename ($path);
=cut
@@ -697,15 +707,15 @@ sub member {
=pod
-=item C<debug($string)>
+=item C<debug($string, ...)>
-The C<debug> function echos the argument string to STDERR in case that
-the global varialbe C<opt_debug> is set.
+The C<debug> function echos the argument strings to STDERR if
+the global variable C<opt_debug> is set.
=cut
sub debug {
- print STDERR @_ if ($::opt_debug);
+ print STDERR "tldbg: @_\n" if $::opt_debug;
}
=pod