I'm trying to execute a remote script with SSH, and this script changes its behavior depending on whether or not a specific argument is empty. Here's a minimal example, where I created a simple tmp.sh
file that echos the number of arguments and then what the arguments are. When I execute it locally, it works as expected, saying it got 3 arguments. But when I execute the script through SSH, it says it only got 2 arguments:
$ cat argtest.sh
#!/bin/bash
echo $#
echo $@
$ ./argtest.sh foo '' bar
3
foo bar
$ ssh user@localhost ./argtest.sh foo '' bar
2
foo bar
Is there a way to get SSH to forward the empty argument, so the script says it got 3 arguments?
Best Answer
Try