Note: this does not work in plain shell but in Bash
The only solution is to indicate to your shell that these are not syntax but actual content, like this :
script.sh $'asd "asd" \'asd\''
# ^^ ^ ^ ^
# || | | |
# 12 3 3 2
1: prefixing a string by $
change its meaning, allowing to backslash-escape quotes, cf https://unix.stackexchange.com/a/30904/383566
2: enclosing the value between single quotes indicate to the shell that it must be treated as a single argument
3: backslash-escaping the single quote, because it is used as enclosing syntax (see 2)
Proof :
# defining a function to test
> function count_and_print_args() { # if not using bash, remove the "function"
echo $# # print the number of arguments
for arg in "$@" # for each of all arguments
do
echo "$arg" # print the argument on a newline
done;
}
> count_and_print_args
0
> count_and_print_args a b c
3
a
b
c
> count_and_print_args $'asd "asd" \'asd\''
1
asd "asd" 'asd'