Skip to content

Commit

Permalink
fix(packages/core): pipeStages splits command with >> incorrectly
Browse files Browse the repository at this point in the history
part of #7413
  • Loading branch information
starpit committed Jul 6, 2021
1 parent 3ca96bb commit 811b6a1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/core/src/repl/pipe-stages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ import { CommandLine } from '../models/command'
*
*/
export function splitIntoPipeStages(command: string): CommandLine['pipeStages'] {
// This covers the standard bash convention of using -- to split the
// command line into a "prefix" part and a "rest" part.
const dashDashPattern = /--\s/
const redirectPattern = /([^"'\\])>/

// This covers > and >>, but excludes '>' and ">" and \> and 2>&1
// WARNING: this regexp uses negaive lookbehind. Firefox only got
// support for this in Firefox version 78 (released July 30 2020).
const redirectPattern = /(?<![\d"'\\])>>?(?![\d&])/

const dashDashMatch = command.match(dashDashPattern)
const pipeStartIdx = dashDashMatch ? dashDashMatch.index + '--'.length : undefined
Expand Down

0 comments on commit 811b6a1

Please sign in to comment.