SPUG: $0 dispatch for named links (on Windows without links)
DeRykus, Charles E
charles.e.derykus at boeing.com
Mon Jun 23 09:42:58 PDT 2008
> I want to have one script that does different things based on $0
(think vi vs vim). If it were > a vanilla *nix issue, I'd make many
hard links and branch based on $0, but since Windows (or
> more accurately some combination of emacs and cygwin creating a useful
interface to the native
> OS) doesn't preserve links across edit cycles, I'm left with one
updated file and N-1 co-linked > old versions.
> I tried to use the 'exec' trick to "lie to the program you are
executing about its own name"
> trick, but it doesn't work on my cygwin (nor even from XP's command
line).
> exec {"$FindBin::Bin/real_name"} 'fake_name', @ARGV;
> Does anyone have a better (for the "less fragile" definition of
"better") suggestion?
Hm, does your scenario preclude just passing
the 'fake_name' as the first argument for
instance:
$0 = shift;
if ( $0 eq "foo" ) { ...
elsif ( ... )
--
Charles DeRykus
More information about the spug-list
mailing list