Skip to main content
1 of 5
Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k

You can use exec -a (as found in bash, ksh93, zsh, mksh, yash but not POSIX yet):

#! /bin/bash -
printf '%s\n' "$0 $*" >> /some/log
exec -a "$0" /usr/bin/real-stuff "$@"

Note that that $0 is not the argv[0] that the command receives. It is the path of the script as passed to execve() (and which is passed as argument to bash), but that's likely to be enough for your purpose.

Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k