linusg linusg - 1 year ago 132
Bash Question

Cross-platform, safe to use command line string separator

For a new feature in

, we need a command line option receiving a string with any separator in it. Here's the discussion:


pyinstaller --add-data="file.txt?dir"

is the separator here, this should be another character. It's not guaranteed, that the string is quoted!

We've thought about
; : > < | *
and so on, but we can't figure out what character would be save to use, without side effects and platform independent (and hopefully not allowed in paths).
e.g will redirect stdout,
is the command separator on POSIX ect.

Any ideas what character we can use?

Answer Source

The best solution for us was using a platform depependent separator:

  • Windows: ;

  • Unix: :

A bit tricky to document, but a clean and save solution.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download