I have a simple bash script that can accept arguments that it will be treating as text strings, nothing more.
If I give it ~
, without quotes, then the home directory /home/users/me
is what's parsed. Quote it, "~"
, it's fine. The character "~" is what I want, not the home path.
Is there any way I can ensure an un-quoted ~
is treated exactly as the character "~", not the home directory alias?
The bash shell is expanding the ~
on the command line before the argument is passed to your script.
There might be a bash option that you can change in your shell, but that would affect everything in your shell, which doesn't sound like what you want.
The short answer I think is no. There's nothing you can do in your script to change how the parent shell expanded any arguments before passing them to your script.