Chris Davies <chris-use...@roaima.co.uk> writes:

[...]

>> 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'

Ahh yes, I see.  Tell sudo to use bash and a specific bash command. 
Thanks.

Darac M's  solution is similarly more direct.


Darac Marjal <mailingl...@darac.org.uk> writes:

[...]

>> >  sudo for ii in 1 2 3;do echo $ii;done 
>> >  bash: syntax error near unexpected token `do'
>
> I suspect the problem here is, perhaps not that sudo doesn't know "do",
> but rather that bash terminates your command at the semi-colon.
>
> Perhaps you should consider why you need to run a for loop as root?
>
> Consider the following:
>  for ii in 1 2 3; do sudo echo $ii; done
> or
>  for ii in $(sudo seq 1 3); do echo $ii; done

Ah yes, your debugging is much more exact. And the usage of sudo is a
more straight forward formulation, just have sudo doing the least
necessary.

Thanks.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/8739ewvmuq....@newsguy.com

Reply via email to