Tailscale -up over multiple lines

When running the tailscale command on my subnet router that is an exit node, I have to advertise quite a few routes. This makes the command hard to read and edit.

Is it possible to split the command over multiple lines, or use a configuration file for this?


tailscale up --advertise-routes=,,,, --accept-routes

The usual way to do this in the shell is to use a backslash to escape the newline:

tailscale up \
    --advertise-routes=,,,, \

Yes, I guess that’s an option, but since it failes in case of whitespace, that doesn’t really make it more readable.

tailscale up --advertise-routes=\,\,\,\,\ \

… would be a bit better (although the backslashes are still ugly), but that fails.

It has to be like this:

tailscale up --advertise-routes=\,\,\,\,\ \

I was hoping there was a better way to do this.

At the risk of becoming a bit StackOverflow and assuming you are happy with a bit of bash, what about:

declare -a routes=(
tailscale up --accept-routes \
    --advertise-routes="$(IFS=, ; echo "${routes[*]}")"
1 Like