air icon indicating copy to clipboard operation
air copied to clipboard

Space not preserved in runtime arguments

Open balki opened this issue 1 year ago • 1 comments

Example:

func main() {
        greeting := flag.String("greeting", "Hello", "")
        name := flag.String("name", "World", "")
        flag.Parse()
        fmt.Println(*greeting, *name)
}

When run directly,

❯ ./tmp/main --name "James Bond"
Hello James Bond

When air runs it, It only prints the first name

❯ ~/go/bin/air           

  __    _   ___  
 / /\  | | | |_) 
/_/--\ |_| |_| \_ , built with Go 

watching .
!exclude tmp
building...
running...
Hello James
^Ccleaning...
see you again~
❯ grep args_bin .air.toml
  args_bin = ["--name", "James Bond"]

It is because the arguments are joined as string below instead which looses quoting information. https://github.com/cosmtrek/air/blob/5ac18a4db4621fecc79d2afb5a4384c2586635de/runner/engine.go#L429

balki avatar Jul 14 '22 15:07 balki

One workaround is to escape the quotes. i.e. args_bin = ["--name", "\"James Bond\""]

balki avatar Jul 18 '22 23:07 balki