I am writing a small script to symbolically link configuration files from my dotfiles directory to another one. I do not have control over the file names and unfortunately one of them is causing me a lot of trouble. The simplest reproducible case I have is as follows:
export file_name='My Configuration Text.theme'
readlink -f $file_name
Which predictably returns:
/home/me/folder/My
/home/me/folder/Configuration
/home/me/folder/Text.theme
I need this to not be split. I have also tried
readlink -f $(printf "%q " $file_name)
And it does not seem to fix the problem. Is there a solution to this or am I better off rewriting my linking script in something more robust like Python?
$file_name
in the call toreadlink
. There is no need toexport
the variable (at least not in relation to your issue or the resolution of it). – Kusalananda May 22 '21 at 17:56