I've been scratching my head over this one for a while now. It seems so simple yet I just can't get it to work. This is on a rooted android tablet, if that makes a difference. I'm trying to imitate the behavior of sudo on a normal linux system. I'm not very experienced when it comes to bash scripting, so this is probably very simple. This is a two part problem.
So here's (part of) a bash script called aliases. It is sourced by bashrc normally. The problem is that I want my custom sudo command to have access to the aliases defined in this script.
#! /system/xbin/bash
alias ls='busybox ls --color=auto'
function sudo() {
su -c 'source /system/etc/bash/aliases && "$@"'
}
So when I call sudo from a shell it outputs absolutely nothing. A quick 'echo ok' at the end of the above script proves that the source command is being executed when I attempt to sudo something. But nothing seems to be done after '&&'. Not even echo. Not even touching a random filename works, so it doesn't seem to be stdout being redirected or something. I've tried substituting '&&' with '||' but that doesn't work either.
Part two of the problem emerged when debugging. Calling the following from a shell:
su -c 'source /system/etc/bash/aliases && ls'
... outputs ls without colors, even though the aliases file was sourced immediately before ls was called. Now I'm thoroughly confused.