Skip to content

Commit

Permalink
Merge pull request #87 from steyep/bugfix/86-space-in-path-var
Browse files Browse the repository at this point in the history
Handles spaces in `$PATH`
  • Loading branch information
steyep authored Nov 8, 2017
2 parents 556de68 + 5699c8d commit 06476c1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/alfred-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ const child = require('child_process');
let shell = process.env.SHELL;
let escChr = str => str.replace(/(["\$])/g, '\\$1');
let escSpace = str => str.replace(/ /g, '\\ ');
const PATH = `eval $(/usr/libexec/path_helper | awk '{print $1}')`;
const PATH = `eval $(echo "$(/usr/libexec/path_helper -s)" | awk -F';' '{ print $1 }');`;

module.exports = {
'exec': (cmd, options, callback) => {
cmd = escChr(cmd);
return child.exec(`${shell} -c "${PATH} ${cmd}"`, options, callback);
cmd = escChr(`${PATH} ${cmd}`);
return child.exec(`${shell} -c "${cmd}"`, options, callback);
},
'execSync': (cmd, options) => {
cmd = escChr(cmd);
return child.execSync(`${shell} -c "${PATH} ${cmd}"`, options);
cmd = escChr(`${PATH} ${cmd}`);
return child.execSync(`${shell} -c "${cmd}"`, options);
},
'spawn': (cmd, args, options) => {
args = args.map(escSpace)
Expand Down

0 comments on commit 06476c1

Please sign in to comment.