Reputation:
I have a file path to a script in a shell variable that if run it directly, it runs fine (the path has a whitespace escaped with a \
there is a white space after the \
), but when I try via
exec $script "$@"
the whitespace becomes in the script path becomes an issues and breaks the path to the script. How can I fix this? (I can't change the given path that has a whitespace in it)
Upvotes: 1
Views: 42
Reputation: 362147
Don't put backslashes into the variable. Quote its expansion.
script="is/already a/string"
exec "$script" "$@"
Upvotes: 4