Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

I am using 'vifm --remote' in a bash script. Here is my bash script:

#!/bin/bash
read -e -p "Enter folder name: " dirName
mkdir "$dirName"
vifm --server-name vifm --remote +"goto \"$dirName\""

This creates new folder for inputs even if they have space, single quotes and/or double quotes. However, I couldn't manage to get the last line (vifm --remote) to work if the input has double quote. How can I escape double quotes in the input arguments that are used in vifm --remote command?

Thank you

1 Answer

+1 vote
by
selected by
 
Best answer

You can try using printf:

vifm --server-name vifm --remote +"goto $(printf %q "$dirName")"

Not sure if it will work in all cases though.

by

YES, this works, thank you!

by

This works great for folders, but it doesn't work for files even if they don't have any special characters. Do you have any suggestions?

by

Never-mind, the issue was becuase of the crash I reported in my other post. I killed vifm and tmux and now is all good. Thank you

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.
...