1

I need to override the first argument when I call a binary.

Since it's the program name I have two solutions:

  • move the binary and call it with its new name; or
  • create an alias (if the shell allows it).

However, sometimes I need to completly remove the first parameter.

I wrote a simple program in C that does the job:

#include <unistd.h>

int main(int argc, char **argv)
{
    return execve(argv[1], NULL, NULL);
}

I there a built-in way to do it with the shell? A solution for bash would be prefered.

0

1 Answer 1

6

You can override it with exec -a, though you can't make it unset.

For example, to run busybox with argv[0] set to ls:

( exec -a ls busybox )

Not the answer you're looking for? Browse other questions tagged or ask your own question.