Skip to content
This repository has been archived by the owner on Nov 11, 2018. It is now read-only.

Be able to call Aliases as well #11

Open
renatomefi opened this issue Feb 8, 2016 · 7 comments
Open

Be able to call Aliases as well #11

renatomefi opened this issue Feb 8, 2016 · 7 comments

Comments

@renatomefi
Copy link

While I was trying the software I immediately tried a command which is an alias in my environment, but maybe was not able to find it. Is it possible to support aliased commands?

The software is awesome, thanks!

@CBrowne
Copy link

CBrowne commented Feb 8, 2016

I noticed this as well, it would be handy but is it possible with the current ptrace implementation?

@daveloyall
Copy link

Could you start your shell under maybe and then issue your command as usual?

@p-e-w
Copy link
Owner

p-e-w commented Feb 9, 2016

Thank you for bringing this up; there is actually a bit more to this issue than it may seem.

Aliases are managed by the shell, for example using bash's alias mechanism. Running an alias is therefore easily accomplished with e.g.

maybe bash -c "alias"

What you are asking for is for maybe to do this automatically.

There are two ways this could work: The first would involve maybe detecting the shell and parsing its aliases to determine which command to actually run. I don't like the sound of that as it would add a lot of complexity on top of what we are currently doing.

The other approach is maybe always invoking the shell, that is, wrapping every command with something like bash -c. This would also add some boilerplate as we cannot just use bash but have to detect the shell first, which isn't pretty either, but there is another problem: If commands are always launched using the shell, every invocation of maybe will result in the actual command being invoked as a subprocess of the shell, and python-ptrace does not support tracing subprocesses on FreeBSD and OpenBSD, so we would essentially lose support for these platforms entirely and be reduced to Linux only.

Alternative suggestions and thoughts are very welcome. It seems that sudo does the right thing, I'd be interested to know how. I just glanced through the source code but the magic puzzle piece appears to elude me.

@sanketplus
Copy link
Contributor

I am not sure but can we do the following:

when the call arguments[0] = locateProgram(arguments[0]) fails,
we can lookup for arguments[0] in
~/.bashrc or /etc/bashrc or some similar place for it's definition or de-aliasing.

Maybe this is very distro specific.

@renatomefi
Copy link
Author

You are right @p-e-w , when I was thinking about the problem I got the idea of calling which in order to find out the alias, since the which command is implemented among all (not sure) the shells this could work. And as @sanketplus said we could do it in case the first call fails!

Other than that using bash -c should be enough! :)

Thanks for looking into this

@dimitrieh
Copy link

for zsh this should work isn't it?


# Enable aliases to be sudo’ed
alias sudo='sudo '
# Enable aliases to be maybe’d
alias maybe='maybe '

@BigAlInTheHouse
Copy link

Code of conduct

-----Original Message-----
From: "Dimitrie Hoekstra" [email protected]
Sent: ‎2/‎18/‎2016 9:16 AM
To: "p-e-w/maybe" [email protected]
Subject: Re: [maybe] Be able to call Aliases as well (#11)

for zsh this should work isn't it?

Enable aliases to be sudo’ed

alias sudo='sudo '

Enable aliases to be maybe’d

alias maybe='maybe '

Reply to this email directly or view it on GitHub.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants