Skip to content

ff0000-ad-tech/unix-path-literal

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unix Path Literal

Different systems can use unix control characters in file/directory names. If trying to render the literal escapes, you may need extra escaping.

Disclaimer: If you're using your spawning module correctly, you do not need this. But if you need to return a Terminal-safe executable string to a view, then this might be handy.

The replacements:

The list is not exhaustive -- just the characters that our users constantly use:

  • -> \
  • ' -> \'
  • ( -> \(
  • ) -> \)
  • - -> \-
  • & -> \&

Install

npm install git://github.com:gmcdev/unix-path-literal.git --save

Usage

const unixPathLiteral = require('unix-path-literal');

const command = `Project/ESPN Wimbledon 2017 -- CLONE/creative (version 1 & '2')/my-bash-script.sh`;
console.log(unixPathLiteral(command));
// => Project/ESPN\ Wimbledon\ 2017\ \-\-\ CLONE/creative\ \(version\ 1\ \&\ \'2\'\)/my\-bash\-script.sh

About

Make a path safe for shell execution.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%