tdenniston / bish

Bish is a language that compiles to Bash. It's designed to give shell scripting a more comfortable and modern feel.
MIT License
1.48k stars 36 forks source link

Running commands from the administrator #28

Closed egorsmkv closed 8 years ago

egorsmkv commented 9 years ago

I would like to ask how it will be implemented?

You can make a semblance of annotations:

@root
cd('/home');

Or like this:

cd('/home') as root;

This is a relevant question, I think, for many users.

noahmorrison commented 9 years ago

By executing the entire file as sudo

$ sudo bish -r /root/bin/example.bish

This is how you would do it in bash as well, unless I'm misunderstanding something.

egorsmkv commented 9 years ago

@noahmorrison I mean the execution of certain commands from the administrator.

noahmorrison commented 9 years ago

@eg0r I'm confused, could you show me an example in bash?

Do you mean something like this?

sudo -u root $cmd
sudo -k
egorsmkv commented 9 years ago

@noahmorrison Yes. Perform certain commands defined by the user.

Excuse me, I use a translator because I have weak English.

noahmorrison commented 9 years ago

It's fine, I might play around with bash implementations this afternoon. I personally like the @root more than the as root. Running full blocks as a user might be something we look at as well.

@root {
    @(yaourt -Syua);
    echo("this is also run as root");
}
egorsmkv commented 9 years ago

It would be wonderful.

tdenniston commented 9 years ago

Overall, this is a good idea. One thing is that the syntax should probably be '@su' for superuser instead of '@root'.

It would also be good to come up with a unified syntax for this and executing normal external commands. For example, we might do @su(...); to match the @(...); syntax. The idea of executing whole external blocks is good too, and it would be fairly straightforward to allow multiple statements within the parens, separated by semicolons.

egorsmkv commented 9 years ago

@tdenniston Need to make the operator that selects the user, not just root.

E.g.: @root(...); or @my-mom(...);.

To execute multiple commands:

@my-dad {
   cd(...);
   # ...
}