Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9143027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:55:21+00:00 2026-06-17T09:55:21+00:00

I’ve been scratching my head over this one for a while now. It seems

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:55:22+00:00Added an answer on June 17, 2026 at 9:55 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.