[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#852451: ITP: rname -- invoke a program under a different name



On Tue, 24 Jan 2017 17:19:49 +0200 Peter Pentchev <roam@ringlet.net> wrote:
> The rname utility invokes a specified program, passing a different name
> instead of the name of the program executable.  This could be useful in
> a number of cases, both during software development, testing, and in
> production use.  There are many programs that do different things based
> on what name they have been invoked under; the rname utility avoids
> the need to e.g. create ephemeral symlinks to run these programs in
> some conditions when they have not been completely installed.
> 
> I originally wrote this tool in 2000 and I'm resurrecting it now for
> the purpose of writing unit and integration tests for just such
> a multifaceted program.

What kind of test environment do you plan to use rname from?  Not trying
to suggest that you shouldn't package it, but I wanted to call attention
to a little-known feature of the bash exec builtin:

~$ (exec sh -c 'echo $0')
sh
~$ (exec -a differentname sh -c 'echo $0')
differentname

That unfortunately doesn't work in portable sh, though; rname seems like
an appropriate option if you can more easily require rname than
requiring bash (or a better scripting/testing language).

- Josh Triplett


Reply to: