question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Solution to apostrophes within filenames used in shell commands?

See original GitHub issue

Node 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:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
HaveAGitGatcommented, May 5, 2019

Thanks that actually works perfectly, much appreciated.

0reactions
nfischercommented, May 6, 2019

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-proxy should handle most security/usability concerns.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found