Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsh

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsh - npm Package Compare versions

Comparing version 0.1.8 to 0.1.10

48

lib/vm.js

@@ -102,4 +102,14 @@ var waitfor = require('./waitfor'),

function addNewlines(cmd) {
var i = 0, addingNewLine = false, inConditional = false, inString = false, stringChar = '';
var i = 0, addingNewLine = false, inConditional = false, inString = false, stringChar = '', inBracketedVar = false, leavingBracketedVar = false;
while (cmd[i]) {
if (!inString && cmd[i] === '$' && cmd[i + 1] === '{') {
inBracketedVar = true;
}
if (leavingBracketedVar) {
leavingBracketedVar = false;
inBracketedVar = false;
}
if (!inString && inBracketedVar && cmd[i] === '}') {
leavingBracketedVar = true;
}
if (!inString && (cmd[i] === '"' || cmd[i] === '\'') && cmd[i - 1] !== '\\') {

@@ -134,7 +144,7 @@ inString = true;

} else if (!inString) {
if (cmd[i] === '{') {
if (!inBracketedVar && cmd[i] === '{') {
cmd = cmd.substr(0, i - 1) + '\n' + '{' + '\n' + cmd.substr(i + 1);
i += 3;
continue;
} else if (cmd[i] === '}') {
} else if (!inBracketedVar && cmd[i] === '}') {
cmd = cmd.substr(0, i - 1) + '\n' + '}' + '\n' + cmd.substr(i + 1);

@@ -169,7 +179,7 @@ i += 3;

function substituteVars (cmd) {
var i = 0, start = false, seq = '', j, escapeNext = false;
var i = 0, start = false, seq = '', j, escapeNext = false, inBrackets = false, inString = '';
while (cmd[i]) {
if (start || seq) {
start = false;
if (/[^\w\$]/.test(cmd[i])) {
if (!inBrackets && /[^\w\$]/.test(cmd[i])) {
cmd = cmd.substr(0, i - seq.length - 1) + '\' + ' + seq + ' + \'' + cmd.substr(i);

@@ -180,2 +190,22 @@ i += 7;

}
if (!inString && (cmd[i] === '\'' || cmd[i] === '"')) {
inString = cmd[i];
seq += cmd[i];
i++;
continue;
}
if (inString) {
if (cmd[i] === inString && !(cmd[i - 1] === '\\' && cmd[i - 2] === '\\')) {
inString = '';
}
seq += cmd[i];
i++;
continue;
}
if (inBrackets && cmd[i] === '}') {
cmd = cmd.substr(0, i - seq.length - 2) + '\' + ' + seq.replace(/\\'/g, '\'') + ' + \'' + cmd.substr(i + 1);
i += 7;
seq = '';
continue;
}
seq += cmd[i];

@@ -195,3 +225,3 @@ i++;

}
if (cmd[i] === '$') {
if (cmd[i] === '$' && cmd[i + 1] !== '{') {
start = true;

@@ -201,2 +231,8 @@ i++;

}
if (cmd[i] === '{' && cmd[i - 1] === '$') {
start = true;
inBrackets = true;
i++;
continue;
}
i++;

@@ -203,0 +239,0 @@ }

2

package.json
{
"name": "jsh",
"version": "0.1.8",
"version": "0.1.10",
"description": "The JavaScript/shell interpreter.",

@@ -5,0 +5,0 @@ "main": "index.js",

# jsh - The JavaScript Shell
This is a UNIX command-line interpreter which sits on top of both Node.js and sh, allowing you to simultaneously execute JavaScript and shell commands. It is fully compatible with Node modules, and preloads all the built-in Node modules at initialization, as well as any modules in ~/.jsh/node_modules, automatically converting to camel-case where necessary.
jsh is a UNIX command-line interpreter which sits on top of both Node.js and sh, allowing you to simultaneously execute JavaScript and shell commands. It is fully compatible with Node modules, and preloads all the built-in Node modules at initialization, as well as any modules in ~/.jsh/node_modules, automatically converting to camel-case where necessary.
In shell commands, you can use the $ character to substitute a variable from the JavaScript environment.
In shell commands, you can use the $ character to substitute a variable from the JavaScript environment. Alternatively you can surround any JavaScript expression in brackets and precede it with a $ character to perform substitutions.

@@ -33,2 +33,9 @@ ## Installation:

An example with brackets:
```
$ function removetxt (v) {
.. rm ${v + '.txt'}
.. }
```
jsh comes with full tab-completion, and you can preload JavaScript in your jsh environment by adding it to your .jshrc, in your home folder. jsh will automatically create this file the first time it is run.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc