air
air copied to clipboard
Space not preserved in runtime arguments
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
One workaround is to escape the quotes. i.e. args_bin = ["--name", "\"James Bond\""]