I am writing a script which takes a directory name from user, then find files inside it. The script may fail if the user use some special characters with their directory name.
$ var="-foobar";
$ find "$var";
find: unknown predicate `-foobar'
For a lot of commands, it is easy to avoid the problem by giving -- to indicate that it is an end of options. But it does not with with find:
$ find -- "$var";
find: unknown predicate `-foobar'
What should I do to handle directory with unpredictable characters?