Re: How to expand sudo environment when -E doesn't
Harry Putnam <reader@newsguy.com> wrote:
> I find sudo to be particularly ill informed at times.
> sudo for ii in 1 2 3;do echo $ii;done
> bash: syntax error near unexpected token `do'
> It doesn't know about bash builtins.
Why should it?
> Adding the -E flag (preserve environment) doe not help at all.
> sudo -E for ii in 1 2 3;do echo $ii;done
> bash: syntax error near unexpected token `do'
Why should it?
> What can I do to avoid this kind of silliness? What kind of
> environment variable would even tell sudo about bash builtins?
There isn't one. You can't use bash builtins like that in any
command. Instead, you should consider a construct like this:
sudo bash -c 'for ii in 1 2 3; do echo $ii; done'
Chris
Reply to: