Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit 1d725ab

Browse files
committed
Lex empty input to []. Fixes #430.
1 parent a57d0e3 commit 1d725ab

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/CommandExpander.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export async function expandAliases(lexemes: string[]): Promise<string[]> {
2626
}
2727

2828
export function lex(input: string): string[] {
29+
if (input.length === 0) {
30+
return [];
31+
}
32+
2933
let lexemes = input.match(/"(?:\\"|[^"])+"|'(?:\\'|[^'])+'|(?:[^ ]+\\ )+[^ ]+|[^ ]+/g);
3034

3135
if (input.endsWith(" ")) {

test/lexer_spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import {expect} from "chai";
22
import {lex} from "../src/CommandExpander";
33

44
describe("lex", () => {
5+
it("returns an empty array on empty input", () => {
6+
expect(lex("")).to.eql([]);
7+
});
8+
59
it("splits on a space", () => {
610
expect(lex("some words")).to.eql(["some", "words"]);
711
});

test/pty_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {expect} from "chai";
22
import PTY from "../src/PTY";
33

44
describe("PTY", () => {
5-
it.only("doesn't interpolate expressions inside single quotes", (done) => {
5+
it("doesn't interpolate expressions inside single quotes", (done) => {
66
let output = "";
77
new PTY(
88
"echo", ["'$('"], process.env, {columns: 80, rows: 30},

0 commit comments

Comments
 (0)