Solution to apostrophes within filenames used in shell commands?
See original GitHub issueNode version (or tell us if you’re using electron or some other framework):
v10.15.3
ShellJS version (the most recent version/Github branch you see the bug on):
“shelljs”: “^0.8.3”,
Operating system:
Windows 10
Description of the bug:
Apostrophes in filenames causing this error:
Syntax Error "(" unexpected
Example ShellJS command to reproduce the error:
nice -n 10 HandBrakeCLI -i '/home/haveagitgat/Desktop/Input/Test's.mp4' -o '/home/haveagitgat/Desktop/Output/Test's.mp4' -Z "Very Fast 1080p30
I’ve tried using double quotes around the file names but then I get errors when filenames contain special characters such as ‘$’.
References: https://github.com/HaveAGitGat/HBBatchBeast/issues/21 https://github.com/HaveAGitGat/HBBatchBeast/issues/32
Any solutions without having to rename the files?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Removing apostrophe from all file names - Unix Stack Exchange
You could try something like this ( bash ): shopt -s nullglob for i in *\'* ; do mv -v "$i" "${i/\'/}" ;...
Read more >Replace a pattern containing an apostrophe within a file
Save the pattern in a shell variable and use double quotes: replacement="set stime = '0 4'" pattern="set stime = '0 0'".
Read more >Why do some of my Linux filenames contain apostrophes?
Original question: Why do some of my Linux filenames contain apostrophes? Spaces are the natural command line argument delimiters in Linux/UNIX shells.
Read more >apostrophe and space together in linux cat command? - Stack ...
Would you please try: sh -c "cat 'test'\''s dir/test'\''s file.txt'". As for the pathname part, it is a concatenation of:
Read more >Why does ls wrap some filenames in single quotes?
ls wraps single quotes around filenames with spaces in them, for the purpose of allowing the filenames to be safely copied, used in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks that actually works perfectly, much appreciated.
We’re looking to add a similar (and more secure) solution to ShellJS proper. That work is tracked in #495. For now, I believe
shelljs-exec-proxyshould handle most security/usability concerns.