3 ms·
> alias sudo=su -c This will not work. sudo cp aaa bbb will work but su -c cp aaa bbb will complain that the user aaa does not exist, you need to quote them in
by dependenttypes 6y ago
> alias sudo=su -c
This will not work. sudo cp aaa bbb will work but su -c cp aaa bbb will complain that the user aaa does not exist, you need to quote them instead, like su -c "cp aaa bbb".
It would make more sense to make it a script
#!/bin/sh
su -c "$@"
- jabirali 6y agoOr make it a shell function that operates on $@ in the same way, so you can put it in your bashrc with your aliases.
- dheera 6y agoI tried this but didn't work: ~ :) gudo () { su -c "$@"; } ~ :) gudo echo foo bar su: user foo does not exist
- jabirali 6y agoI searched it up, and apparently "$@" and expands to "foo" "bar" while "$*" expands to "foo bar", and the latter is what we want. From a quick test on my machine, that replacement in in your function definition seems to fix it :).