Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
re-add program name fiddling in $?USAGE
  • Loading branch information
FROGGS committed Sep 30, 2014
1 parent 5a02987 commit b5032fc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/core/Main.pm
Expand Up @@ -68,7 +68,21 @@ my sub MAIN_HELPER($retval = 0) is hidden_from_backtrace {
my sub gen-usage () {
my @help-msgs;

my $prog-name = $*PROGRAM_NAME eq '-e' ?? "-e '...'" !! ~$*PROGRAM.relative;
my sub strip_path_prefix($name) {
my ($vol, $dir, $base) = IO::Spec.splitpath($name);
$dir = IO::Spec.canonpath($dir);
for IO::Spec.path() -> $elem {
if IO::Spec.catpath($vol, $elem, $base).IO.x {
return $base if IO::Spec.canonpath($elem) eq $dir;
# Shadowed command found in earlier PATH element
return $name;
}
}
# Not in PATH
return $name;
}

my $prog-name = $*PROGRAM_NAME eq '-e' ?? "-e '...'" !! strip_path_prefix($*PROGRAM_NAME);
for $m.candidates -> $sub {
my (@required-named, @optional-named, @positional, $docs);
for $sub.signature.params -> $param {
Expand Down

0 comments on commit b5032fc

Please sign in to comment.