Closed warren-lei closed 1 year ago
@warren-lei AFAIK in most Linux systems the tilde expanded by the shell: https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html
What kind of Linux and the shell do you use?
It is probably that the option was set using the =
syntax and the shell
won't expand that since it's in the middle of a word. If you separate the
option and value it will work, or you could use $HOME.
On Mon, 9 Oct 2023, 22:47 Pavel Artemkin, @.***> wrote:
@warren-lei https://github.com/warren-lei AFAIK in most Linux systems the tilde expanded by the shell: https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html
What kind of Linux and the shell do you use?
— Reply to this email directly, view it on GitHub https://github.com/jarro2783/cxxopts/issues/408#issuecomment-1752857856, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALDQ4RR254WJP7D6RSYE63X6PP6PAVCNFSM6AAAAAA5YEPHVOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJSHA2TOOBVGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
It is probably that the option was set using the
=
syntax and the shell won't expand that since it's in the middle of a word. If you separate the option and value it will work, or you could use $HOME. … On Mon, 9 Oct 2023, 22:47 Pavel Artemkin, @.> wrote: @warren-lei https://github.com/warren-lei AFAIK in most Linux systems the tilde expanded by the shell: https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html What kind of Linux and the shell do you use? — Reply to this email directly, view it on GitHub <#408 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALDQ4RR254WJP7D6RSYE63X6PP6PAVCNFSM6AAAAAA5YEPHVOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJSHA2TOOBVGY . You are receiving this because you are subscribed to this thread.Message ID: @.>
Yes, I set the option using the =
syntax. Tilde symbol is expanded by separating the option .
Thanks for help.
But, if any user use my program by setting the option using the =
syntax, The symbol ~
will still be treated as a normal string.
I set the option using the
=
syntax. Tilde symbol is expanded by separating the option .
I set the option using the = syntax. Problem is solved by separating the option .
--model_dir ~/models
I need to pass a model directory to my program by using cxxopts.hpp to parse arguments from command line. Like this:
./my_program --model_dir=~/model/
But tilde symbol (~
) cannot be automatically expanded, which led to my program cannot find the correct path of the models. The tilde symbol (~
) is handled as a normal string in cxxopts.hpp. For example, if the current user is "user1," then ~ should automatically expand to "/home/user1" which is the home directory of user1. I must add this codes after parsing arguments--model_dir
.