I have a script that is essentially a wrapper around an executable with the same name on another machine. For an example, I will wrap printf here. My current script is as follows:
#!/bin/bash ssh user@hostname.tld. printf " $@ "
Unfortunately, this is interrupted when one of the arguments contains a space, for example. I would expect the following commands to get identical outputs:
~$ ./wrap_printf "%s_%s" "hello world" "1" hello_world1_ ~$ printf "%s_%s" "hello world" "1" hello world_1
The problem gets even worse when (escaped) newline characters are involved. How could I escape my arguments here?
source share