Your immediate problem is that you have surrounded your command in single quotes:
su -c 'source /system/etc/bash/aliases && "$@"'
The single quotes mean that the "$@"
is not expanded inside the function, so you're running the literal command...
source /system/etc/bash/aliases && "$@"
...and the "$@"
expands to an empty string. If you can live without needed to handle quoted arguments, you could do this:
su -c "source /system/etc/bash/aliases && $*"
Note the use of double quotes ("..."
) instead of single quotes. However, this may still not do what you need, because of this:
Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt (see the description of shopt under SHELL BUILTIN COMMANDS below).
In general, I try to avoid the use of aliases in shell scripts, because it makes the script heavily dependent on your environment (or in this case, the environment of the target user). Using shell scripts instead of aliases to encapsulate commands will generally result in a more robust and portable solution.