Re: [go-nuts] Re: Using golang variable in bash script Command

2022-09-19 Thread Jan Mercl
On Mon, Sep 19, 2022 at 2:52 PM Amnon  wrote:

> What happens if the user enters the string "'; rm -fr ~;'" ?

https://twitter.com/codepo8/status/1373224835866882048

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-UGc%2BGqd3V1FzePvB745zB1puMoNwoX-UJeJM6wJu_31Q%40mail.gmail.com.


[go-nuts] Re: Using golang variable in bash script Command

2022-09-19 Thread Amnon
What happens if the user enters the string "'; rm -fr ~;'" ?

On Monday, 19 September 2022 at 13:25:31 UTC+1 Brian Candler wrote:

> On Monday, 19 September 2022 at 10:50:36 UTC+1 princ...@gmail.com wrote:
>
>>
>> *search:=scanner.Text()cmd1,err:=exec.Command("bash", "-c", "find . -name 
>> '*$search*'")*
>
>
> You first "search" is a go local variable.
> Your second "$search" is seen by the shell as a reference to an 
> environment variable.
>
> So if you want to do it that way, you need to set it in the environment, 
> e.g. with os.Setenv.
> https://pkg.go.dev/os#Setenv
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e2aafbd7-3f67-4170-aee1-489cf8c26540n%40googlegroups.com.


[go-nuts] Re: Using golang variable in bash script Command

2022-09-19 Thread Brian Candler
On Monday, 19 September 2022 at 10:50:36 UTC+1 princ...@gmail.com wrote:

>
> *search:=scanner.Text()cmd1,err:=exec.Command("bash", "-c", "find . -name 
> '*$search*'")*


You first "search" is a go local variable.
Your second "$search" is seen by the shell as a reference to an environment 
variable.

So if you want to do it that way, you need to set it in the environment, 
e.g. with os.Setenv.
https://pkg.go.dev/os#Setenv

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f7a8dc06-7c2e-4756-9082-d28460eab1den%40googlegroups.com.